[PATCH rdma-core 04/14] tests: BaseResources Class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Maxim Chicherin <maximc@xxxxxxxxxxxx>

Base aggregator object which contains basic resources like Context
and PD.

Signed-off-by: Maxim Chicherin <maximc@xxxxxxxxxxxx>
---
 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
-- 
2.21.0




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux