[PATCH rdma-core 10/19] pyverbs: Add unittests for memory window control path

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

 



This patch tests creation and destruction of memory window.

Signed-off-by: Noa Osherovich <noaos@xxxxxxxxxxxx>
---
 pyverbs/tests/mr.py | 41 +++++++++++++++++++++++++++++++++++++++--
 1 file changed, 39 insertions(+), 2 deletions(-)

diff --git a/pyverbs/tests/mr.py b/pyverbs/tests/mr.py
index 409cd41e3c06..c97c6ac38d6d 100644
--- a/pyverbs/tests/mr.py
+++ b/pyverbs/tests/mr.py
@@ -3,11 +3,11 @@
 import unittest
 import random
 
-from pyverbs.pyverbs_error import PyverbsRDMAError
+from pyverbs.pyverbs_error import PyverbsRDMAError, PyverbsError
 from pyverbs.base import PyverbsRDMAErrno
 import pyverbs.tests.utils as u
+from pyverbs.mr import MR, MW
 import pyverbs.device as d
-from pyverbs.mr import MR
 from pyverbs.pd import PD
 import pyverbs.enums as e
 
@@ -144,3 +144,40 @@ class mr_test(unittest.TestCase):
                     with MR(pd, length, u.get_access_flags()) as mr:
                         buf = mr.buf
 
+
+class mw_test(unittest.TestCase):
+    """
+    Test various functionalities of the MW class.
+    """
+    def test_reg_mw(self):
+        """ Test ibv_alloc_mw() """
+        lst = d.get_device_list()
+        for dev in lst:
+            with d.Context(name=dev.name.decode()) as ctx:
+                with PD(ctx) as pd:
+                    with MW(pd, random.choice([e.IBV_MW_TYPE_1, e.IBV_MW_TYPE_2])) as mw:
+                        pass
+
+    def test_dereg_mw(self):
+        """ Test ibv_dealloc_mw() """
+        lst = d.get_device_list()
+        for dev in lst:
+            with d.Context(name=dev.name.decode()) as ctx:
+                with PD(ctx) as pd:
+                    with MW(pd, random.choice([e.IBV_MW_TYPE_1, e.IBV_MW_TYPE_2])) as mw:
+                        mw.close()
+
+    def test_reg_mw_wrong_type(self):
+        """ Test ibv_alloc_mw() """
+        lst = d.get_device_list()
+        for dev in lst:
+            with d.Context(name=dev.name.decode()) as ctx:
+                with PD(ctx) as pd:
+                    try:
+                        mw_type =random.randint(3, 100)
+                        mw = MW(pd, mw_type)
+                    except PyverbsRDMAError as e:
+                        pass
+                    else:
+                        raise PyverbsError('Created a MW with type {t}'.\
+                                           format(t=mw_type))
-- 
2.17.2




[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