[PATCH RFC] tests: Fix test_mr_rereg_pd

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

 



This patch adds a util method drain_cq which drains out
the cq associated with a client or server. This is then
added to the method restate_qps in tests/test_mr.py.
This allows correct operation when recovering test state
from an error which may have also left stray completions
in the cqs before resetting the qps for use.

Fixes: 4bc72d894481 ("tests: Add rereg MR tests")
Signed-off-by: Bob Pearson <rpearsonhpe@xxxxxxxxx>
---
 tests/test_mr.py |  2 ++
 tests/utils.py   | 14 ++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/tests/test_mr.py b/tests/test_mr.py
index 534df46a..73dfbff2 100644
--- a/tests/test_mr.py
+++ b/tests/test_mr.py
@@ -109,6 +109,8 @@ class MRTest(RDMATestCase):
         self.server.qp.to_rts(self.server_qp_attr)
         self.client.qp.modify(QPAttr(qp_state=e.IBV_QPS_RESET), e.IBV_QP_STATE)
         self.client.qp.to_rts(self.client_qp_attr)
+        u.drain_cq(self.client.cq)
+        u.drain_cq(self.server.cq)
 
     def test_mr_rereg_access(self):
         self.create_players(MRRes)
diff --git a/tests/utils.py b/tests/utils.py
index a1dfa7d8..f6966b1a 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -672,6 +672,20 @@ def poll_cq_ex(cqex, count=1, data=None, sgid=None):
     finally:
         cqex.end_poll()
 
+def drain_cq(cq):
+    """
+    Drain completions from a CQ.
+    :param cq: CQ to drain
+    :return: None
+    """
+    channel = cq.comp_channel
+    while 1:
+        if channel:
+            channel.get_cq_event(cq)
+            cq.req_notify()
+        nc, tmp_wcs = cq.poll(1)
+        if nc == 0:
+            break
 
 def validate(received_str, is_server, msg_size):
     """
-- 
2.39.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