From patchwork Mon Aug 19 06:58:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 11100339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB85C174A for ; Mon, 19 Aug 2019 06:58:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBB8D285B9 for ; Mon, 19 Aug 2019 06:58:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0382285B8; Mon, 19 Aug 2019 06:58:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AD8E285A0 for ; Mon, 19 Aug 2019 06:58:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726550AbfHSG6f (ORCPT ); Mon, 19 Aug 2019 02:58:35 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:53156 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726736AbfHSG6e (ORCPT ); Mon, 19 Aug 2019 02:58:34 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Aug 2019 09:58:30 +0300 Received: from reg-l-vrt-059-007.mtl.labs.mlnx (reg-l-vrt-059-007.mtl.labs.mlnx [10.135.59.7]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x7J6wUNG004602; Mon, 19 Aug 2019 09:58:30 +0300 From: Noa Osherovich To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com Cc: linux-rdma@vger.kernel.org, Maxim Chicherin Subject: [PATCH rdma-core 04/14] tests: BaseResources Class Date: Mon, 19 Aug 2019 09:58:17 +0300 Message-Id: <20190819065827.26921-5-noaos@mellanox.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190819065827.26921-1-noaos@mellanox.com> References: <20190819065827.26921-1-noaos@mellanox.com> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Maxim Chicherin Base aggregator object which contains basic resources like Context and PD. Signed-off-by: Maxim Chicherin --- tests/base.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/base.py b/tests/base.py index a1eae2becdc0..88f00e07b326 100644 --- a/tests/base.py +++ b/tests/base.py @@ -3,7 +3,10 @@ import unittest +from pyverbs.device import Context import pyverbs.device as d +from pyverbs.pd import PD + class PyverbsAPITestCase(unittest.TestCase): def setUp(self): @@ -21,3 +24,22 @@ class PyverbsAPITestCase(unittest.TestCase): def tearDown(self): for tup in self.devices: tup[0].close() + + +class BaseResources(object): + """ + BaseResources class is a base aggregator object which contains basic + resources like Context and PD. It opens a context over the given device + and port and allocates a PD. + """ + def __init__(self, dev_name, ib_port, gid_index): + """ + Initializes a BaseResources object. + :param dev_name: Device name to be used (default: 'ibp0s8f0') + :param ib_port: IB port of the device to use (default: 1) + :param gid_index: Which GID index to use (default: 0) + """ + self.ctx = Context(name=dev_name) + self.gid_index = gid_index + self.pd = PD(self.ctx) + self.ib_port = ib_port