linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rdma-core 00/14] rdma-core tests infrastructure
@ 2019-08-19  6:58 Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 01/14] pyverbs/tests: Rename base class Noa Osherovich
                   ` (13 more replies)
  0 siblings, 14 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Noa Osherovich

Currently, rdma-core provides no test suite for users/developers.
This means that for users, there is no way to sanity-check a fresh
installation, and for developers, no comfortable API to write tests
to be shipped along new features.
This series is changing the way we use pyverbs for tests and provides
an easy-to-use classes and methods to make tests development fast.
A testing.md file is available under the Documentation directory,
explaining the design and usage in details.
This PR also unifies the output of the current API tests, so when
executed in verbose mode, the output will be the same for all tests.

Maxim Chicherin (7):
  tests: BaseResources Class
  tests: RDMATestCase
  tests: RCResources and UDResources classes
  tests: ODP requires decorator
  tests: Add traffic helper methods
  tests: Add ODP RC test
  tests: Add ODP UD test

Noa Osherovich (7):
  pyverbs/tests: Rename base class
  pyverbs: Move tests to a stand-alone directory
  build: Add pyverbs-based test to the build
  tests: TrafficResources class
  tests: Fix test locating process
  Documentation: Add background for rdma-core tests
  tests: Unify API tests' output

 CMakeLists.txt                                |  11 +
 Documentation/testing.md                      | 126 ++++++++
 buildlib/pyverbs_functions.cmake              |   7 +
 debian/python3-pyverbs.install                |   2 +
 pyverbs/CMakeLists.txt                        |  17 -
 pyverbs/run_tests.py                          |  22 --
 pyverbs/tests/__init__.py                     |   0
 pyverbs/tests/base.py                         |  23 --
 redhat/rdma-core.spec                         |   2 +
 run_tests.py                                  |  16 +
 suse/rdma-core.spec                           |   2 +
 tests/CMakeLists.txt                          |  15 +
 tests/__init__.py                             |  17 +
 tests/base.py                                 | 293 ++++++++++++++++++
 pyverbs/tests/addr.py => tests/test_addr.py   |   4 +-
 pyverbs/tests/cq.py => tests/test_cq.py       |  10 +-
 .../tests/device.py => tests/test_device.py   |  12 +-
 pyverbs/tests/mr.py => tests/test_mr.py       |  46 ++-
 tests/test_odp.py                             |  41 +++
 pyverbs/tests/pd.py => tests/test_pd.py       |   4 +-
 pyverbs/tests/qp.py => tests/test_qp.py       |   6 +-
 {pyverbs/tests => tests}/utils.py             | 199 ++++++++++++
 22 files changed, 782 insertions(+), 93 deletions(-)
 create mode 100644 Documentation/testing.md
 delete mode 100644 pyverbs/run_tests.py
 delete mode 100644 pyverbs/tests/__init__.py
 delete mode 100644 pyverbs/tests/base.py
 create mode 100644 run_tests.py
 create mode 100644 tests/CMakeLists.txt
 create mode 100644 tests/__init__.py
 create mode 100644 tests/base.py
 rename pyverbs/tests/addr.py => tests/test_addr.py (97%)
 rename pyverbs/tests/cq.py => tests/test_cq.py (97%)
 rename pyverbs/tests/device.py => tests/test_device.py (97%)
 rename pyverbs/tests/mr.py => tests/test_mr.py (90%)
 create mode 100644 tests/test_odp.py
 rename pyverbs/tests/pd.py => tests/test_pd.py (95%)
 rename pyverbs/tests/qp.py => tests/test_qp.py (98%)
 rename {pyverbs/tests => tests}/utils.py (52%)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 01/14] pyverbs/tests: Rename base class
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 02/14] pyverbs: Move tests to a stand-alone directory Noa Osherovich
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Noa Osherovich

Rename PyverbsTestCase to PyverbsAPITestCase as a preparation for
addition of feature-based tests.

Signed-off-by: Noa Osherovich <noaos@mellanox.com>
---
 pyverbs/tests/addr.py   | 4 ++--
 pyverbs/tests/base.py   | 2 +-
 pyverbs/tests/cq.py     | 8 ++++----
 pyverbs/tests/device.py | 4 ++--
 pyverbs/tests/mr.py     | 8 ++++----
 pyverbs/tests/pd.py     | 4 ++--
 pyverbs/tests/qp.py     | 4 ++--
 7 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/pyverbs/tests/addr.py b/pyverbs/tests/addr.py
index 1326eec0d0f6..1c56f56bd0bd 100644
--- a/pyverbs/tests/addr.py
+++ b/pyverbs/tests/addr.py
@@ -1,15 +1,15 @@
 # SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB)
 # Copyright (c) 2019 Mellanox Technologies, Inc. All rights reserved.  See COPYING file
 
+from pyverbs.tests.base import PyverbsAPITestCase
 from pyverbs.addr import GlobalRoute, AHAttr, AH
 from pyverbs.pyverbs_error import PyverbsError
-from pyverbs.tests.base import PyverbsTestCase
 import pyverbs.device as d
 import pyverbs.enums as e
 from pyverbs.pd import PD
 from pyverbs.cq import WC
 
-class AHTest(PyverbsTestCase):
+class AHTest(PyverbsAPITestCase):
     """
     Test various functionalities of the AH class.
     """
diff --git a/pyverbs/tests/base.py b/pyverbs/tests/base.py
index 9541e61b0d55..a1eae2becdc0 100644
--- a/pyverbs/tests/base.py
+++ b/pyverbs/tests/base.py
@@ -5,7 +5,7 @@ import unittest
 
 import pyverbs.device as d
 
-class PyverbsTestCase(unittest.TestCase):
+class PyverbsAPITestCase(unittest.TestCase):
     def setUp(self):
         """
         Opens the devices and queries them
diff --git a/pyverbs/tests/cq.py b/pyverbs/tests/cq.py
index 38f145f865ba..e1e56d363011 100644
--- a/pyverbs/tests/cq.py
+++ b/pyverbs/tests/cq.py
@@ -7,12 +7,12 @@ import random
 
 from pyverbs.cq import CompChannel, CQ, CqInitAttrEx, CQEX
 from pyverbs.pyverbs_error import PyverbsError
-from pyverbs.tests.base import PyverbsTestCase
+from pyverbs.tests.base import PyverbsAPITestCase
 import pyverbs.tests.utils as u
 import pyverbs.enums as e
 
 
-class CQTest(PyverbsTestCase):
+class CQTest(PyverbsAPITestCase):
     """
     Test various functionalities of the CQ class.
     """
@@ -84,7 +84,7 @@ class CQTest(PyverbsTestCase):
                 cq.close()
 
 
-class CCTest(PyverbsTestCase):
+class CCTest(PyverbsAPITestCase):
     """
     Test various functionalities of the Completion Channel class.
     """
@@ -105,7 +105,7 @@ class CCTest(PyverbsTestCase):
             cc.close()
 
 
-class CQEXTest(PyverbsTestCase):
+class CQEXTest(PyverbsAPITestCase):
     """
     Test various functionalities of the CQEX class.
     """
diff --git a/pyverbs/tests/device.py b/pyverbs/tests/device.py
index 54ff438d12fa..63f195156119 100644
--- a/pyverbs/tests/device.py
+++ b/pyverbs/tests/device.py
@@ -8,7 +8,7 @@ import resource
 import random
 
 from pyverbs.pyverbs_error import PyverbsError, PyverbsRDMAError
-from pyverbs.tests.base import PyverbsTestCase
+from pyverbs.tests.base import PyverbsAPITestCase
 import pyverbs.tests.utils as u
 import pyverbs.device as d
 
@@ -137,7 +137,7 @@ class DeviceTest(unittest.TestCase):
                         format(p=port))
 
 
-class DMTest(PyverbsTestCase):
+class DMTest(PyverbsAPITestCase):
     """
     Test various functionalities of the DM class.
     """
diff --git a/pyverbs/tests/mr.py b/pyverbs/tests/mr.py
index e303fd575de4..4be3987fc18b 100644
--- a/pyverbs/tests/mr.py
+++ b/pyverbs/tests/mr.py
@@ -7,7 +7,7 @@ from itertools import combinations as com
 import random
 
 from pyverbs.pyverbs_error import PyverbsRDMAError, PyverbsError
-from pyverbs.tests.base import PyverbsTestCase
+from pyverbs.tests.base import PyverbsAPITestCase
 from pyverbs.base import PyverbsRDMAErrno
 from pyverbs.mr import MR, MW, DMMR
 import pyverbs.tests.utils as u
@@ -18,7 +18,7 @@ import pyverbs.enums as e
 MAX_IO_LEN = 1048576
 
 
-class MRTest(PyverbsTestCase):
+class MRTest(PyverbsAPITestCase):
     """
     Test various functionalities of the MR class.
     """
@@ -154,7 +154,7 @@ class MRTest(PyverbsTestCase):
                         mr.buf
 
 
-class MWTest(PyverbsTestCase):
+class MWTest(PyverbsAPITestCase):
     """
     Test various functionalities of the MW class.
     """
@@ -200,7 +200,7 @@ class MWTest(PyverbsTestCase):
                                        format(t=mw_type))
 
 
-class DMMRTest(PyverbsTestCase):
+class DMMRTest(PyverbsAPITestCase):
     """
     Test various functionalities of the DMMR class.
     """
diff --git a/pyverbs/tests/pd.py b/pyverbs/tests/pd.py
index 5072a4a35de1..87528db7d437 100644
--- a/pyverbs/tests/pd.py
+++ b/pyverbs/tests/pd.py
@@ -5,13 +5,13 @@ Test module for pyverbs' pd module.
 """
 import random
 
-from pyverbs.tests.base import PyverbsTestCase
+from pyverbs.tests.base import PyverbsAPITestCase
 from pyverbs.base import PyverbsRDMAErrno
 import pyverbs.device as d
 from pyverbs.pd import PD
 
 
-class PDTest(PyverbsTestCase):
+class PDTest(PyverbsAPITestCase):
     """
     Test various functionalities of the PD class.
     """
diff --git a/pyverbs/tests/qp.py b/pyverbs/tests/qp.py
index be152d4ca5bd..bbf28244f641 100644
--- a/pyverbs/tests/qp.py
+++ b/pyverbs/tests/qp.py
@@ -5,7 +5,7 @@ Test module for pyverbs' qp module.
 """
 import random
 
-from pyverbs.tests.base import PyverbsTestCase
+from pyverbs.tests.base import PyverbsAPITestCase
 from pyverbs.qp import QPInitAttr, QPAttr, QP
 import pyverbs.tests.utils as u
 import pyverbs.enums as e
@@ -13,7 +13,7 @@ from pyverbs.pd import PD
 from pyverbs.cq import CQ
 
 
-class QPTest(PyverbsTestCase):
+class QPTest(PyverbsAPITestCase):
     """
     Test various functionalities of the QP class.
     """
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 02/14] pyverbs: Move tests to a stand-alone directory
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 01/14] pyverbs/tests: Rename base class Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build Noa Osherovich
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Noa Osherovich

Unittests can be added regardless of pyverbs, change the directory
hierarchy to reflect that.

Signed-off-by: Noa Osherovich <noaos@mellanox.com>
---
 tests/CMakeLists.txt                            | 14 ++++++++++++++
 {pyverbs/tests => tests}/__init__.py            |  0
 {pyverbs/tests => tests}/base.py                |  0
 pyverbs/tests/addr.py => tests/test_addr.py     |  2 +-
 pyverbs/tests/cq.py => tests/test_cq.py         |  4 ++--
 pyverbs/tests/device.py => tests/test_device.py |  4 ++--
 pyverbs/tests/mr.py => tests/test_mr.py         |  4 ++--
 pyverbs/tests/pd.py => tests/test_pd.py         |  2 +-
 pyverbs/tests/qp.py => tests/test_qp.py         |  4 ++--
 {pyverbs/tests => tests}/utils.py               |  0
 10 files changed, 24 insertions(+), 10 deletions(-)
 create mode 100644 tests/CMakeLists.txt
 rename {pyverbs/tests => tests}/__init__.py (100%)
 rename {pyverbs/tests => tests}/base.py (100%)
 rename pyverbs/tests/addr.py => tests/test_addr.py (98%)
 rename pyverbs/tests/cq.py => tests/test_cq.py (98%)
 rename pyverbs/tests/device.py => tests/test_device.py (99%)
 rename pyverbs/tests/mr.py => tests/test_mr.py (99%)
 rename pyverbs/tests/pd.py => tests/test_pd.py (97%)
 rename pyverbs/tests/qp.py => tests/test_qp.py (99%)
 rename {pyverbs/tests => tests}/utils.py (100%)

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 000000000000..f1ba542fab90
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB)
+# Copyright (c) 2019, Mellanox Technologies. All rights reserved. See COPYING file
+
+rdma_python_test(tests
+  __init__.py
+  test_addr.py
+  base.py
+  test_cq.py
+  test_device.py
+  test_mr.py
+  test_pd.py
+  test_qp.py
+  utils.py
+  )
diff --git a/pyverbs/tests/__init__.py b/tests/__init__.py
similarity index 100%
rename from pyverbs/tests/__init__.py
rename to tests/__init__.py
diff --git a/pyverbs/tests/base.py b/tests/base.py
similarity index 100%
rename from pyverbs/tests/base.py
rename to tests/base.py
diff --git a/pyverbs/tests/addr.py b/tests/test_addr.py
similarity index 98%
rename from pyverbs/tests/addr.py
rename to tests/test_addr.py
index 1c56f56bd0bd..9cc801226e69 100644
--- a/pyverbs/tests/addr.py
+++ b/tests/test_addr.py
@@ -1,9 +1,9 @@
 # SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB)
 # Copyright (c) 2019 Mellanox Technologies, Inc. All rights reserved.  See COPYING file
 
-from pyverbs.tests.base import PyverbsAPITestCase
 from pyverbs.addr import GlobalRoute, AHAttr, AH
 from pyverbs.pyverbs_error import PyverbsError
+from tests.base import PyverbsAPITestCase
 import pyverbs.device as d
 import pyverbs.enums as e
 from pyverbs.pd import PD
diff --git a/pyverbs/tests/cq.py b/tests/test_cq.py
similarity index 98%
rename from pyverbs/tests/cq.py
rename to tests/test_cq.py
index e1e56d363011..7848f39c9c63 100644
--- a/pyverbs/tests/cq.py
+++ b/tests/test_cq.py
@@ -7,9 +7,9 @@ import random
 
 from pyverbs.cq import CompChannel, CQ, CqInitAttrEx, CQEX
 from pyverbs.pyverbs_error import PyverbsError
-from pyverbs.tests.base import PyverbsAPITestCase
-import pyverbs.tests.utils as u
+from tests.base import PyverbsAPITestCase
 import pyverbs.enums as e
+import tests.utils as u
 
 
 class CQTest(PyverbsAPITestCase):
diff --git a/pyverbs/tests/device.py b/tests/test_device.py
similarity index 99%
rename from pyverbs/tests/device.py
rename to tests/test_device.py
index 63f195156119..e395e793c28f 100644
--- a/pyverbs/tests/device.py
+++ b/tests/test_device.py
@@ -8,8 +8,8 @@ import resource
 import random
 
 from pyverbs.pyverbs_error import PyverbsError, PyverbsRDMAError
-from pyverbs.tests.base import PyverbsAPITestCase
-import pyverbs.tests.utils as u
+from tests.base import PyverbsAPITestCase
+import tests.utils as u
 import pyverbs.device as d
 
 PAGE_SIZE = resource.getpagesize()
diff --git a/pyverbs/tests/mr.py b/tests/test_mr.py
similarity index 99%
rename from pyverbs/tests/mr.py
rename to tests/test_mr.py
index 4be3987fc18b..e87fb33624ed 100644
--- a/pyverbs/tests/mr.py
+++ b/tests/test_mr.py
@@ -7,13 +7,13 @@ from itertools import combinations as com
 import random
 
 from pyverbs.pyverbs_error import PyverbsRDMAError, PyverbsError
-from pyverbs.tests.base import PyverbsAPITestCase
+from tests.base import PyverbsAPITestCase
 from pyverbs.base import PyverbsRDMAErrno
 from pyverbs.mr import MR, MW, DMMR
-import pyverbs.tests.utils as u
 import pyverbs.device as d
 from pyverbs.pd import PD
 import pyverbs.enums as e
+import tests.utils as u
 
 MAX_IO_LEN = 1048576
 
diff --git a/pyverbs/tests/pd.py b/tests/test_pd.py
similarity index 97%
rename from pyverbs/tests/pd.py
rename to tests/test_pd.py
index 87528db7d437..978cf4900146 100644
--- a/pyverbs/tests/pd.py
+++ b/tests/test_pd.py
@@ -5,7 +5,7 @@ Test module for pyverbs' pd module.
 """
 import random
 
-from pyverbs.tests.base import PyverbsAPITestCase
+from tests.base import PyverbsAPITestCase
 from pyverbs.base import PyverbsRDMAErrno
 import pyverbs.device as d
 from pyverbs.pd import PD
diff --git a/pyverbs/tests/qp.py b/tests/test_qp.py
similarity index 99%
rename from pyverbs/tests/qp.py
rename to tests/test_qp.py
index bbf28244f641..1ce98388871b 100644
--- a/pyverbs/tests/qp.py
+++ b/tests/test_qp.py
@@ -5,12 +5,12 @@ Test module for pyverbs' qp module.
 """
 import random
 
-from pyverbs.tests.base import PyverbsAPITestCase
 from pyverbs.qp import QPInitAttr, QPAttr, QP
-import pyverbs.tests.utils as u
+from tests.base import PyverbsAPITestCase
 import pyverbs.enums as e
 from pyverbs.pd import PD
 from pyverbs.cq import CQ
+import tests.utils as u
 
 
 class QPTest(PyverbsAPITestCase):
diff --git a/pyverbs/tests/utils.py b/tests/utils.py
similarity index 100%
rename from pyverbs/tests/utils.py
rename to tests/utils.py
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 01/14] pyverbs/tests: Rename base class Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 02/14] pyverbs: Move tests to a stand-alone directory Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  2019-08-19 13:50   ` Jason Gunthorpe
  2019-08-19  6:58 ` [PATCH rdma-core 04/14] tests: BaseResources Class Noa Osherovich
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Noa Osherovich

Have the tests installed separately from pyverbs as they're not a
part of the package. They will now be placed under
/usr/share/doc/rdma-core-{version}/tests.
The tests can be executed as follows:
python3 /usr/share/doc/rdma-core-{version}/run_tests.py

Signed-off-by: Noa Osherovich <noaos@mellanox.com>
---
 CMakeLists.txt                       | 11 +++++++++++
 buildlib/pyverbs_functions.cmake     |  7 +++++++
 debian/python3-pyverbs.install       |  2 ++
 pyverbs/CMakeLists.txt               | 17 -----------------
 redhat/rdma-core.spec                |  2 ++
 pyverbs/run_tests.py => run_tests.py |  0
 suse/rdma-core.spec                  |  2 ++
 7 files changed, 24 insertions(+), 17 deletions(-)
 rename pyverbs/run_tests.py => run_tests.py (100%)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fc17ef36cf24..d076ab2c9d3a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -648,6 +648,7 @@ add_subdirectory(infiniband-diags/man)
 
 if (CYTHON_EXECUTABLE)
   add_subdirectory(pyverbs)
+  add_subdirectory(tests)
 endif()
 
 # Binaries
@@ -666,6 +667,16 @@ if (UDEV_FOUND)
 endif()
 add_subdirectory(srp_daemon)
 
+if (CYTHON_EXECUTABLE)
+rdma_python_test(""
+  run_tests.py
+  )
+
+rdma_internal_binary(
+  run_tests.py
+  )
+endif()
+
 ibverbs_finalize()
 rdma_finalize_libs()
 
diff --git a/buildlib/pyverbs_functions.cmake b/buildlib/pyverbs_functions.cmake
index 9d5258617035..8ea5dc0df7de 100644
--- a/buildlib/pyverbs_functions.cmake
+++ b/buildlib/pyverbs_functions.cmake
@@ -35,6 +35,13 @@ function(rdma_python_module PY_MODULE)
   endforeach()
 endfunction()
 
+function(rdma_python_test PY_MODULE)
+  foreach(PY_FILE ${ARGN})
+    install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PY_FILE}
+      DESTINATION ${CMAKE_INSTALL_DOCDIR}/${PY_MODULE})
+  endforeach()
+endfunction()
+
 # Make a python script runnable from the build/bin directory with all the
 # correct paths filled in
 function(rdma_internal_binary)
diff --git a/debian/python3-pyverbs.install b/debian/python3-pyverbs.install
index 20130d8a9a03..10efb97232fd 100644
--- a/debian/python3-pyverbs.install
+++ b/debian/python3-pyverbs.install
@@ -1 +1,3 @@
 usr/lib/python3/dist-packages/pyverbs
+usr/share/doc/rdma-core/run_tests.py
+usr/share/doc/rdma-core/tests
diff --git a/pyverbs/CMakeLists.txt b/pyverbs/CMakeLists.txt
index 328263fcc739..da49093c2cf0 100644
--- a/pyverbs/CMakeLists.txt
+++ b/pyverbs/CMakeLists.txt
@@ -16,22 +16,5 @@ rdma_cython_module(pyverbs
 rdma_python_module(pyverbs
   __init__.py
   pyverbs_error.py
-  run_tests.py
   utils.py
   )
-
-rdma_python_module(pyverbs/tests
-  tests/__init__.py
-  tests/addr.py
-  tests/base.py
-  tests/cq.py
-  tests/device.py
-  tests/mr.py
-  tests/pd.py
-  tests/qp.py
-  tests/utils.py
-  )
-
-rdma_internal_binary(
-  run_tests.py
-  )
diff --git a/redhat/rdma-core.spec b/redhat/rdma-core.spec
index f07919ccecd5..239c56b581e8 100644
--- a/redhat/rdma-core.spec
+++ b/redhat/rdma-core.spec
@@ -650,4 +650,6 @@ rm -rf %{buildroot}/%{_sbindir}/srp_daemon.sh
 %if %{with_pyverbs}
 %files -n python3-pyverbs
 %{python3_sitearch}/pyverbs
+%{_docdir}/%{name}-%{version}/tests/*.py
+%{_docdir}/%{name}-%{version}/run_tests.py
 %endif
diff --git a/pyverbs/run_tests.py b/run_tests.py
similarity index 100%
rename from pyverbs/run_tests.py
rename to run_tests.py
diff --git a/suse/rdma-core.spec b/suse/rdma-core.spec
index 5a01327c4852..cdb6793e4f75 100644
--- a/suse/rdma-core.spec
+++ b/suse/rdma-core.spec
@@ -852,6 +852,8 @@ rm -rf %{buildroot}/%{_sbindir}/srp_daemon.sh
 %if %{with_pyverbs}
 %files -n python3-pyverbs
 %{python3_sitearch}/pyverbs
+%{_docdir}/%{name}-%{version}/tests/*.py
+%{_docdir}/%{name}-%{version}/run_tests.py
 %endif
 
 %changelog
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 04/14] tests: BaseResources Class
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
                   ` (2 preceding siblings ...)
  2019-08-19  6:58 ` [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 05/14] tests: RDMATestCase Noa Osherovich
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Maxim Chicherin

From: Maxim Chicherin <maximc@mellanox.com>

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

Signed-off-by: Maxim Chicherin <maximc@mellanox.com>
---
 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


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 05/14] tests: RDMATestCase
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
                   ` (3 preceding siblings ...)
  2019-08-19  6:58 ` [PATCH rdma-core 04/14] tests: BaseResources Class Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 06/14] tests: TrafficResources class Noa Osherovich
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Maxim Chicherin, Noa Osherovich

From: Maxim Chicherin <maximc@mellanox.com>

Base class for future tests which allows user-set parameters:
device name, IB port, GID index and PKey index can be provided to the
tests. If not, they're selected at random.

Signed-off-by: Maxim Chicherin <maximc@mellanox.com>
Signed-off-by: Noa Osherovich <noaos@mellanox.com>
---
 tests/base.py | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 101 insertions(+)

diff --git a/tests/base.py b/tests/base.py
index 88f00e07b326..e141b83dea0e 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -2,9 +2,11 @@
 # Copyright (c) 2019 Mellanox Technologies, Inc . All rights reserved. See COPYING file
 
 import unittest
+import random
 
 from pyverbs.device import Context
 import pyverbs.device as d
+import pyverbs.enums as e
 from pyverbs.pd import PD
 
 
@@ -26,6 +28,105 @@ class PyverbsAPITestCase(unittest.TestCase):
             tup[0].close()
 
 
+class RDMATestCase(unittest.TestCase):
+    """
+    A base class for test cases which provides the option for user parameters.
+    These can be provided by manually adding the test case to the runner:
+    suite = unittest.TestSuite()
+    ... # Regular auto-detection of test cases, no parameters used.
+    # Now follows your manual addition of test cases e.g:
+    suite.addTest(RDMATestCase.parametrize(<TestCaseName>, dev_name='..',
+                                           ib_port=1, gid_index=3,
+                                           pkey_index=42))
+    """
+    ZERO_GID = '0000:0000:0000:0000'
+
+    def __init__(self, methodName='runTest', dev_name=None, ib_port=None,
+                 gid_index=None, pkey_index=None):
+        super(RDMATestCase, self).__init__(methodName)
+        self.dev_name = dev_name
+        self.ib_port = ib_port
+        self.gid_index = gid_index
+        self.pkey_index = pkey_index
+
+    @staticmethod
+    def parametrize(testcase_klass, dev_name=None, ib_port=None, gid_index=None,
+                    pkey_index=None):
+        """
+        Create a test suite containing all the tests from the given subclass
+        with the given dev_name, port, gid index and pkey_index.
+        """
+        loader = unittest.TestLoader()
+        names = loader.getTestCaseNames(testcase_klass)
+        suite = unittest.TestSuite()
+        for n in names:
+            suite.addTest(testcase_klass(n, dev_name=dev_name, ib_port=ib_port,
+                                         gid_index=gid_index,
+                                         pkey_index=pkey_index))
+        return suite
+
+    def setUp(self):
+        """
+        Verify that the test case has dev_name, ib_port, gid_index and pkey index.
+        If not provided by the user, a random valid combination will be used.
+        """
+        if self.pkey_index is None:
+            # To avoid iterating the entire pkeys table, if a pkey index wasn't
+            # provided, use index 0 which is always valid
+            self.pkey_index = 0
+
+        self.args = []
+        if self.dev_name is not None:
+            ctx = d.Context(name=self.dev_name)
+            if self.ib_port is not None:
+                if self.gid_index is not None:
+                    # We have all we need, return
+                    return
+                else:
+                    # Add avaiable GIDs of the given dev_name + port
+                    self._add_gids_per_port(ctx, self.dev_name, self.ib_port)
+            else:
+                # Add available GIDs for each port of the given dev_name
+                self._add_gids_per_device(ctx, self.dev_name)
+        else:
+            # Iterate available devices, add available GIDs for each of
+            # their ports
+            lst = d.get_device_list()
+            for dev in lst:
+                dev_name = dev.name.decode()
+                ctx = d.Context(name=dev_name)
+                self._add_gids_per_device(ctx, dev_name)
+
+        if not self.args:
+            raise unittest.SkipTest('No dev/port/GID combinations, please check your setup and try again')
+        # Choose one combination and use it
+        args = random.choice(self.args)
+        self.dev_name = args[0]
+        self.ib_port = args[1]
+        self.gid_index = args[2]
+
+    def _add_gids_per_port(self, ctx, dev, port):
+        idx = 0
+        ll = ctx.query_port(port).link_layer
+        while True:
+            gid = ctx.query_gid(port, idx)
+            if gid.gid[-19:] == self.ZERO_GID:
+                # No point iterating on
+                break
+            if ll == e.IBV_LINK_LAYER_ETHERNET and gid.gid[0:4] == 'fe80':
+                # Use only IPv4/IPv6 GIDs
+                idx += 1
+                continue
+            else:
+                self.args.append([dev, port, idx])
+                idx += 1
+
+    def _add_gids_per_device(self, ctx, dev):
+        port_count = ctx.query_device().phys_port_cnt
+        for port in range(port_count):
+            self._add_gids_per_port(ctx, dev, port+1)
+
+
 class BaseResources(object):
     """
     BaseResources class is a base aggregator object which contains basic
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 06/14] tests: TrafficResources class
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
                   ` (4 preceding siblings ...)
  2019-08-19  6:58 ` [PATCH rdma-core 05/14] tests: RDMATestCase Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 07/14] tests: RCResources and UDResources classes Noa Osherovich
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Noa Osherovich, Maxim Chicherin

Basic traffic aggregation object which contains MR, CQ and QP. It
also provides common control path functions to create these objects.

Signed-off-by: Maxim Chicherin <maximc@mellanox.com>
Signed-off-by: Noa Osherovich <noaos@mellanox.com>
---
 tests/base.py  | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/utils.py | 20 ++++++++++++
 2 files changed, 105 insertions(+)

diff --git a/tests/base.py b/tests/base.py
index e141b83dea0e..54ebac27d522 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -4,10 +4,15 @@
 import unittest
 import random
 
+from pyverbs.pyverbs_error import PyverbsError, PyverbsRDMAError
+from pyverbs.qp import QPCap, QPInitAttr, QPAttr, QP
+from tests.utils import wc_status_to_str
 from pyverbs.device import Context
 import pyverbs.device as d
 import pyverbs.enums as e
 from pyverbs.pd import PD
+from pyverbs.cq import CQ
+from pyverbs.mr import MR
 
 
 class PyverbsAPITestCase(unittest.TestCase):
@@ -144,3 +149,83 @@ class BaseResources(object):
         self.gid_index = gid_index
         self.pd = PD(self.ctx)
         self.ib_port = ib_port
+
+
+class TrafficResources(BaseResources):
+    """
+    Basic traffic class. It provides the basic RDMA resources and operations
+    needed for traffic.
+    """
+    def __init__(self, dev_name, ib_port, gid_index):
+        """
+        Initializes a TrafficResources object with the given values and creates
+        basic RDMA resources.
+        :param dev_name: Device name to be used
+        :param ib_port: IB port of the device to use
+        :param gid_index: Which GID index to use
+        """
+        super(TrafficResources, self).__init__(dev_name=dev_name,
+                                               ib_port=ib_port,
+                                               gid_index=gid_index)
+        self.psn = random.getrandbits(24)
+        self.msg_size = 1024
+        self.num_msgs = 1000
+        self.port_attr = None
+        self.mr = None
+        self.cq = None
+        self.qp = None
+        self.rqpn = 0
+        self.rpsn = 0
+        self.init_resources()
+
+    @property
+    def qpn(self):
+        return self.qp.qp_num
+
+    def init_resources(self):
+        """
+        Initializes a CQ, MR and an RC QP.
+        :return: None
+        """
+        self.port_attr = self.ctx.query_port(self.ib_port)
+        self.create_cq()
+        self.create_mr()
+        self.create_qp()
+
+    def create_cq(self):
+        """
+        Initializes self.cq with a CQ of depth <num_msgs> - defined by each
+        test.
+        :return: None
+        """
+        self.cq = CQ(self.ctx, self.num_msgs, None, None, 0)
+
+    def create_mr(self):
+        """
+        Initializes self.mr with an MR of length <msg_size> - defined by each
+        test.
+        :return: None
+        """
+        self.mr = MR(self.pd, self.msg_size, e.IBV_ACCESS_LOCAL_WRITE)
+
+    def create_qp(self):
+        """
+        Initializes self.qp with an RC QP.
+        :return: None
+        """
+        qp_caps = QPCap(max_recv_wr=self.num_msgs)
+        qp_init_attr = QPInitAttr(qp_type=e.IBV_QPT_RC, scq=self.cq,
+                                  rcq=self.cq, cap=qp_caps)
+        qp_attr = QPAttr(port_num=self.ib_port)
+        self.qp = QP(self.pd, qp_init_attr, qp_attr)
+
+    def pre_run(self, rpsn, rqpn):
+        """
+        Modify the QP's state to RTS and fill receive queue with <num_msgs> work
+        requests.
+        This method is not implemented in this class.
+        :param rpsn: Remote PSN
+        :param rqpn: Remote QPN
+        :return: None
+        """
+        raise NotImplementedError()
diff --git a/tests/utils.py b/tests/utils.py
index c84865a10a40..30166f41d555 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -221,3 +221,23 @@ def random_qp_init_attr_ex(attr_ex, attr, qpt=None):
     qia = QPInitAttrEx(qp_type=qpt, cap=qp_cap, sq_sig_all=sig, comp_mask=mask,
                        create_flags=cflags, max_tso_header=max_tso)
     return qia
+
+
+def wc_status_to_str(status):
+    try:
+        return \
+            {0: 'Success', 1: 'Local length error',
+             2: 'local QP operation error', 3: 'Local EEC operation error',
+             4: 'Local protection error', 5: 'WR flush error',
+             6: 'Memory window bind error', 7: 'Bad response error',
+             8: 'Local access error', 9: 'Remote invalidate request error',
+             10: 'Remote access error', 11: 'Remote operation error',
+             12: 'Retry exceeded', 13: 'RNR retry exceeded',
+             14: 'Local RDD violation error',
+             15: 'Remote invalidate RD request error',
+             16: 'Remote aort error', 17: 'Invalidate EECN error',
+             18: 'Invalidate EEC state error', 19: 'Fatal error',
+             20: 'Response timeout error', 21: 'General error'}[status]
+    except KeyError:
+        return 'Unknown WC status ({s})'.format(s=status)
+
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 07/14] tests: RCResources and UDResources classes
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
                   ` (5 preceding siblings ...)
  2019-08-19  6:58 ` [PATCH rdma-core 06/14] tests: TrafficResources class Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 08/14] tests: ODP requires decorator Noa Osherovich
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Maxim Chicherin

From: Maxim Chicherin <maximc@mellanox.com>

Add RC and UD specific aggregation objects. They provide
traffic-specific implementations for control path functions such as
modify QP.

Signed-off-by: Maxim Chicherin <maximc@mellanox.com>
---
 tests/base.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 64 insertions(+), 2 deletions(-)

diff --git a/tests/base.py b/tests/base.py
index 54ebac27d522..a28e9b9dc466 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -4,9 +4,8 @@
 import unittest
 import random
 
-from pyverbs.pyverbs_error import PyverbsError, PyverbsRDMAError
 from pyverbs.qp import QPCap, QPInitAttr, QPAttr, QP
-from tests.utils import wc_status_to_str
+from pyverbs.addr import AHAttr, GlobalRoute
 from pyverbs.device import Context
 import pyverbs.device as d
 import pyverbs.enums as e
@@ -229,3 +228,66 @@ class TrafficResources(BaseResources):
         :return: None
         """
         raise NotImplementedError()
+
+
+class RCResources(TrafficResources):
+    PATH_MTU = e.IBV_MTU_1024
+    MAX_DEST_RD_ATOMIC = 1
+    MAX_RD_ATOMIC = 1
+    MIN_RNR_TIMER =12
+    RETRY_CNT = 7
+    RNR_RETRY = 7
+    TIMEOUT = 14
+
+    def to_rts(self, rpsn, rqpn):
+        """
+        Set the QP attributes' values to arbitrary values (same values used in
+        ibv_rc_pingpong).
+        :param rpsn: Remote PSN (packet serial number)
+        :param rqpn: Remote QP number
+        :return: None
+        """
+        attr = QPAttr(port_num=self.ib_port)
+        attr.dest_qp_num = rqpn
+        attr.path_mtu = self.PATH_MTU
+        attr.max_dest_rd_atomic = self.MAX_DEST_RD_ATOMIC
+        attr.min_rnr_timer = self.MIN_RNR_TIMER
+        attr.rq_psn = rpsn
+        attr.sq_psn = self.psn
+        attr.timeout = self.TIMEOUT
+        attr.retry_cnt = self.RETRY_CNT
+        attr.rnr_retry = self.RNR_RETRY
+        attr.max_rd_atomic = self.MAX_RD_ATOMIC
+        gr = GlobalRoute(dgid=self.ctx.query_gid(self.ib_port, self.gid_index),
+                         sgid_index=self.gid_index)
+        ah_attr = AHAttr(port_num=self.ib_port, is_global=1, gr=gr,
+                         dlid=self.port_attr.lid)
+        attr.ah_attr = ah_attr
+        self.qp.to_rts(attr)
+
+    def pre_run(self, rpsn, rqpn):
+        self.rqpn = rqpn
+        self.rpsn = rpsn
+        self.to_rts(rpsn, rqpn)
+
+
+class UDResources(TrafficResources):
+    UD_QKEY = 0x11111111
+    UD_PKEY_INDEX = 0
+
+    def create_mr(self):
+        self.mr = MR(self.pd, self.msg_size + self.GRH_SIZE,
+                     e.IBV_ACCESS_LOCAL_WRITE)
+
+    def create_qp(self):
+        qp_caps = QPCap(max_recv_wr=self.num_msgs)
+        qp_init_attr = QPInitAttr(qp_type=e.IBV_QPT_UD, cap=qp_caps,
+                                  scq=self.cq, rcq=self.cq)
+        qp_attr = QPAttr(port_num=self.ib_port)
+        qp_attr.qkey = self.UD_QKEY
+        qp_attr.pkey_index = self.UD_PKEY_INDEX
+        self.qp = QP(self.pd, qp_init_attr, qp_attr)
+
+    def pre_run(self, rpsn, rqpn):
+        self.rqpn = rqpn
+        self.rpsn = rpsn
\ No newline at end of file
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 08/14] tests: ODP requires decorator
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
                   ` (6 preceding siblings ...)
  2019-08-19  6:58 ` [PATCH rdma-core 07/14] tests: RCResources and UDResources classes Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 09/14] tests: Add traffic helper methods Noa Osherovich
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Maxim Chicherin

From: Maxim Chicherin <maximc@mellanox.com>

Add a 'requires_odp' decorator, to be used when registering an MR with
ON_DEMAND access flag.

Signed-off-by: Maxim Chicherin <maximc@mellanox.com>
---
 tests/utils.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tests/utils.py b/tests/utils.py
index 30166f41d555..20a7e8d38e54 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -5,6 +5,7 @@ Provide some useful helper function for pyverbs' tests.
 """
 from itertools import combinations as com
 from string import ascii_lowercase as al
+import unittest
 import random
 
 from pyverbs.qp import QPCap, QPInitAttrEx
@@ -241,3 +242,32 @@ def wc_status_to_str(status):
     except KeyError:
         return 'Unknown WC status ({s})'.format(s=status)
 
+
+# Decorators
+
+def requires_odp(qp_type):
+    def outer(func):
+        def inner(instance):
+            odp_supported(instance.ctx, qp_type)
+            return func(instance)
+        return inner
+    return outer
+
+
+def odp_supported(ctx, qp_type):
+    """
+    Check device ODP capabilities, support only send/recv so far.
+    :param ctx: Device Context
+    :param qp_type: QP type ('rc', 'ud' or 'uc')
+    :return: None
+    """
+    odp_caps = ctx.query_device_ex().odp_caps
+    if odp_caps.general_caps == 0:
+        raise unittest.SkipTest('ODP is not supported - No ODP caps')
+    qp_odp_caps = getattr(odp_caps, '{}_odp_caps'.format(qp_type))
+    has_odp_send = qp_odp_caps & e.IBV_ODP_SUPPORT_SEND
+    has_odp_recv = qp_odp_caps & e.IBV_ODP_SUPPORT_RECV
+    if has_odp_send == 0:
+        raise unittest.SkipTest('ODP is not supported - ODP send not supported')
+    if has_odp_recv == 0:
+        raise unittest.SkipTest('ODP is not supported - ODP recv not supported')
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 09/14] tests: Add traffic helper methods
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
                   ` (7 preceding siblings ...)
  2019-08-19  6:58 ` [PATCH rdma-core 08/14] tests: ODP requires decorator Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 10/14] tests: Add ODP RC test Noa Osherovich
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Maxim Chicherin

From: Maxim Chicherin <maximc@mellanox.com>

This patch adds common methods needed for data path such as creation
of send/recv work requests, post_send/recv wrappers etc.

Signed-off-by: Maxim Chicherin <maximc@mellanox.com>
---
 tests/utils.py | 151 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 150 insertions(+), 1 deletion(-)

diff --git a/tests/utils.py b/tests/utils.py
index 20a7e8d38e54..881ce4d03634 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -8,6 +8,9 @@ from string import ascii_lowercase as al
 import unittest
 import random
 
+from pyverbs.pyverbs_error import PyverbsError, PyverbsRDMAError
+from pyverbs.addr import AHAttr, AH, GlobalRoute
+from pyverbs.wr import SGE, SendWR, RecvWR
 from pyverbs.qp import QPCap, QPInitAttrEx
 import pyverbs.device as d
 import pyverbs.enums as e
@@ -23,6 +26,7 @@ MIN_DM_LOG_ALIGN = 0
 MAX_DM_LOG_ALIGN = 6
 # Raw Packet QP supports TSO header, which creates a larger send WQE.
 MAX_RAW_PACKET_SEND_WR = 2500
+GRH_SIZE = 40
 
 
 def get_mr_length():
@@ -242,9 +246,154 @@ def wc_status_to_str(status):
     except KeyError:
         return 'Unknown WC status ({s})'.format(s=status)
 
+# Traffic helpers
+
+def get_send_wr(agr_obj, is_server):
+    """
+    Creates a single SGE Send WR for agr_obj's QP type. The content of the
+    message is either 's' for server side or 'c' for client side.
+    :param agr_obj: Aggregation object which contains all resources necessary
+    :param is_server: Indicates whether this is server or client side
+    :return: send wr
+    """
+    qp_type = agr_obj.qp.qp_type
+    mr = agr_obj.mr
+    if qp_type == e.IBV_QPT_UD:
+        send_sge = SGE(mr.buf + GRH_SIZE, agr_obj.msg_size, mr.lkey)
+    else:
+        send_sge = SGE(mr.buf, agr_obj.msg_size, mr.lkey)
+    msg = agr_obj.msg_size * ('s' if is_server else 'c')
+    mr.write(msg, agr_obj.msg_size)
+    return SendWR(num_sge=1, sg=[send_sge])
+
+
+def get_recv_wr(agr_obj):
+    """
+    Creates a single SGE Recv WR for agr_obj's QP type.
+    :param agr_obj: Aggregation object which contains all resources necessary
+    :return: recv wr
+    """
+    qp_type = agr_obj.qp.qp_type
+    mr = agr_obj.mr
+    if qp_type == e.IBV_QPT_UD:
+        recv_sge = SGE(mr.buf, agr_obj.msg_size + GRH_SIZE, mr.lkey)
+    else:
+        recv_sge = SGE(mr.buf, agr_obj.msg_size, mr.lkey)
+    return RecvWR(sg=[recv_sge], num_sge=1)
+
+
+def post_send(agr_obj, send_wr, gid_index, port):
+    """
+    Post a single send WR to the QP. Post_send's second parameter (send bad wr)
+    is ignored for simplicity. For UD traffic an address vector is added as
+    well.
+    :param agr_obj: aggregation object which contains all resources necessary
+    :param send_wr: Send work request to post send
+    :param gid_index: Local gid index
+    :param port: IB port number
+    :return: None
+    """
+    qp_type = agr_obj.qp.qp_type
+    if qp_type == e.IBV_QPT_UD:
+        gr = GlobalRoute(dgid=agr_obj.ctx.query_gid(port, gid_index),
+                         sgid_index=gid_index)
+        ah_attr = AHAttr(port_num=port, is_global=1, gr=gr,
+                         dlid=agr_obj.port_attr.lid)
+        ah = AH(agr_obj.pd, attr=ah_attr)
+        send_wr.set_wr_ud(ah, agr_obj.rqpn, agr_obj.UD_QKEY)
+    agr_obj.qp.post_send(send_wr, None)
+
+
+def post_recv(qp, recv_wr, num_wqes=1):
+    """
+    Call the QP's post_recv() method <num_wqes> times. Post_recv's second
+    parameter (recv bad wr) is ignored for simplicity.
+    :param qp: QP which posts receive work request
+    :param recv_wr: Receive work request to post
+    :param num_wqes: Number of WQEs to post
+    :return: None
+    """
+    for _ in range(num_wqes):
+        qp.post_recv(recv_wr, None)
 
-# Decorators
 
+def poll_cq(cq, count=1):
+    """
+    Poll <count> completions from the CQ.
+    Note: This function calls the blocking poll() method of the CQ
+    until <count> completions were received. Alternatively, gets a
+    single CQ event when events are used.
+    :param cq: CQ to poll from
+    :param count: How many completions to poll
+    :return: An array of work completions of length <count>, None
+             when events are used
+    """
+    wcs = None
+    while count > 0:
+        nc, wcs = cq.poll(count)
+        for wc in wcs:
+            if wc.status != e.IBV_WC_SUCCESS:
+                raise PyverbsRDMAError('Completion status is {s}'.
+                                       format(s=wc_status_to_str(wc.status)))
+        count -= nc
+    return wcs
+
+
+def validate(received_str, is_server, msg_size):
+    """
+    Validates the received buffer against the expected result.
+    The application should set client's send buffer to 'c's and the
+    server's send buffer to 's's.
+    If the expected buffer is different than the actual, an exception will
+    be raised.
+    :param received_str: The received buffer to check
+    :param is_server: Indicates whether this is the server (receiver) or
+                      client side
+    :param msg_size: the message size of the received packet
+    :return: None
+    """
+    expected_str = msg_size * ('c' if is_server else 's')
+    received_str = received_str.decode()
+    if received_str[0:msg_size] == \
+            expected_str[0:msg_size]:
+        return
+    else:
+        raise PyverbsError(
+            'Data validation failure: expected {exp}, received {rcv}'.
+                format(exp=expected_str, rcv=received_str))
+
+
+def traffic(client, server, iters, gid_idx, port):
+    """
+    Runs basic traffic between two sides
+    :param client: client side, clients base class is BaseTraffic
+    :param server: server side, servers base class is BaseTraffic
+    :param iters: number of traffic iterations
+    :param gid_idx: local gid index
+    :param port: IB port
+    :return:
+    """
+    s_recv_wr = get_recv_wr(server)
+    c_recv_wr = get_recv_wr(client)
+    post_recv(client.qp, c_recv_wr, client.num_msgs)
+    post_recv(server.qp, s_recv_wr, server.num_msgs)
+    for _ in range(iters):
+        c_send_wr = get_send_wr(client, False)
+        post_send(client, c_send_wr, gid_idx, port)
+        poll_cq(client.cq)
+        poll_cq(server.cq)
+        post_recv(client.qp, c_recv_wr)
+        msg_received = server.mr.read(server.msg_size, 0)
+        validate(msg_received, True, server.msg_size)
+        s_send_wr = get_send_wr(server, True)
+        post_send(server, s_send_wr, gid_idx, port)
+        poll_cq(server.cq)
+        poll_cq(client.cq)
+        post_recv(server.qp, s_recv_wr)
+        msg_received = client.mr.read(client.msg_size, 0)
+        validate(msg_received, False, client.msg_size)
+
+# Decorators
 def requires_odp(qp_type):
     def outer(func):
         def inner(instance):
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 10/14] tests: Add ODP RC test
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
                   ` (8 preceding siblings ...)
  2019-08-19  6:58 ` [PATCH rdma-core 09/14] tests: Add traffic helper methods Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 11/14] tests: Add ODP UD test Noa Osherovich
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Maxim Chicherin, Noa Osherovich

From: Maxim Chicherin <maximc@mellanox.com>

Add a TestCase for ODP/RC traffic.

Signed-off-by: Maxim Chicherin <maximc@mellanox.com>
Signed-off-by: Noa Osherovich <noaos@mellanox.com>
---
 tests/CMakeLists.txt |  1 +
 tests/test_odp.py    | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100644 tests/test_odp.py

diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index f1ba542fab90..6f3c23cd1ec0 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -10,5 +10,6 @@ rdma_python_test(tests
   test_mr.py
   test_pd.py
   test_qp.py
+  test_odp.py
   utils.py
   )
diff --git a/tests/test_odp.py b/tests/test_odp.py
new file mode 100644
index 000000000000..a9f3bf4573a5
--- /dev/null
+++ b/tests/test_odp.py
@@ -0,0 +1,30 @@
+from tests.base import RDMATestCase
+from tests.utils import requires_odp, traffic
+from tests.base import RCResources
+from pyverbs.mr import MR
+import pyverbs.enums as e
+
+
+class OdpRC(RCResources):
+    @requires_odp('rc')
+    def create_mr(self):
+        self.mr = MR(self.pd, self.msg_size,
+                     e.IBV_ACCESS_LOCAL_WRITE | e.IBV_ACCESS_ON_DEMAND)
+
+
+class OdpTestCase(RDMATestCase):
+    def setUp(self):
+        super(OdpTestCase, self).setUp()
+        self.iters = 100
+        self.qp_dict = {'rc': OdpRC}
+
+    def create_players(self, qp_type):
+        client = self.qp_dict[qp_type](self.dev_name, self.ib_port, self.gid_index)
+        server = self.qp_dict[qp_type](self.dev_name, self.ib_port, self.gid_index)
+        client.pre_run(server.psn, server.qpn)
+        server.pre_run(client.psn, client.qpn)
+        return client, server
+
+    def test_odp_rc_traffic(self):
+        client, server = self.create_players('rc')
+        traffic(client, server, self.iters, self.gid_index, self.ib_port)
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 11/14] tests: Add ODP UD test
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
                   ` (9 preceding siblings ...)
  2019-08-19  6:58 ` [PATCH rdma-core 10/14] tests: Add ODP RC test Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 12/14] tests: Fix test locating process Noa Osherovich
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Maxim Chicherin

From: Maxim Chicherin <maximc@mellanox.com>

Add a TestCase for ODP/UD traffic.

Signed-off-by: Maxim Chicherin <maximc@mellanox.com>
---
 tests/test_odp.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tests/test_odp.py b/tests/test_odp.py
index a9f3bf4573a5..922cd0d9aad5 100644
--- a/tests/test_odp.py
+++ b/tests/test_odp.py
@@ -1,10 +1,17 @@
 from tests.base import RDMATestCase
 from tests.utils import requires_odp, traffic
-from tests.base import RCResources
+from tests.base import RCResources, UDResources
 from pyverbs.mr import MR
 import pyverbs.enums as e
 
 
+class OdpUD(UDResources):
+    @requires_odp('ud')
+    def create_mr(self):
+        self.mr = MR(self.pd, self.msg_size + self.GRH_SIZE ,
+                     e.IBV_ACCESS_LOCAL_WRITE | e.IBV_ACCESS_ON_DEMAND)
+
+
 class OdpRC(RCResources):
     @requires_odp('rc')
     def create_mr(self):
@@ -16,7 +23,7 @@ class OdpTestCase(RDMATestCase):
     def setUp(self):
         super(OdpTestCase, self).setUp()
         self.iters = 100
-        self.qp_dict = {'rc': OdpRC}
+        self.qp_dict = {'rc': OdpRC, 'ud': OdpUD}
 
     def create_players(self, qp_type):
         client = self.qp_dict[qp_type](self.dev_name, self.ib_port, self.gid_index)
@@ -28,3 +35,7 @@ class OdpTestCase(RDMATestCase):
     def test_odp_rc_traffic(self):
         client, server = self.create_players('rc')
         traffic(client, server, self.iters, self.gid_index, self.ib_port)
+
+    def test_odp_ud_traffic(self):
+        client, server = self.create_players('ud')
+        traffic(client, server, self.iters, self.gid_index, self.ib_port)
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 12/14] tests: Fix test locating process
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
                   ` (10 preceding siblings ...)
  2019-08-19  6:58 ` [PATCH rdma-core 11/14] tests: Add ODP UD test Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 13/14] Documentation: Add background for rdma-core tests Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 14/14] tests: Unify API tests' output Noa Osherovich
  13 siblings, 0 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Noa Osherovich

Add a module-specific load_tests method in __init__.py. It currently
locates all existing tests under its directory (files should start
with 'test_') and runs them without any parameters. In order to run a
test with a specific set of parameters, user can add the relevant
lines in __init__.py (example provided in the file).

Signed-off-by: Noa Osherovich <noaos@mellanox.com>
---
 run_tests.py      | 20 +++++++-------------
 tests/__init__.py | 17 +++++++++++++++++
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index dbee92d942bd..4f6b212dab9f 100644
--- a/run_tests.py
+++ b/run_tests.py
@@ -1,22 +1,16 @@
 # SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB)
 # Copyright (c) 2018, Mellanox Technologies. All rights reserved.  See COPYING file
-import unittest,os,os.path,fnmatch
-import tests
 
+import unittest
 
+
+# Run from /usr/share/doc/rdma-core-<version>
 def test_all():
-    # FIXME: This implementation is for older Python versions, will
-    # be replaced with discover()
-    return test_suite
+    module = __import__('tests')
+    loader = unittest.TestLoader()
+    suite = loader.loadTestsFromModule(module)
+    return suite
 
-module = __import__("tests")
-fns = [os.path.splitext(I)[0] for I in fnmatch.filter(os.listdir(module.__path__[0]),"*.py")]
-fns.remove("__init__")
-for I in fns:
-    __import__("tests." + I)
-test_suite = unittest.TestSuite(unittest.defaultTestLoader.loadTestsFromNames(fns,module))
 
 if __name__ == '__main__':
     unittest.main(defaultTest="test_all")
-
-
diff --git a/tests/__init__.py b/tests/__init__.py
index e69de29bb2d1..7a2efdfb6e6b 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB)
+# Copyright (c) 2019 Mellanox Technologies, Inc . All rights reserved. See COPYING file
+
+import unittest
+
+
+def load_tests(loader, standard_tests, pattern):
+    loader = unittest.TestLoader()
+    suite = loader.discover('tests')
+    return suite
+#   To run only some test cases / parametrized tests:
+#   1. Add RDMATestCase to the imports:
+#    from tests.base import RDMATestCase
+#   2. Replace the current TestSuite with a customized one and add tests to it
+#      (parameters are optional)
+#    suite = unittest.TestSuite()
+#    suite.addTest(RDMATestCase.parametrize(YourTestCase, dev_name='rocep0s8f0', ...))
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 13/14] Documentation: Add background for rdma-core tests
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
                   ` (11 preceding siblings ...)
  2019-08-19  6:58 ` [PATCH rdma-core 12/14] tests: Fix test locating process Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  2019-08-19  6:58 ` [PATCH rdma-core 14/14] tests: Unify API tests' output Noa Osherovich
  13 siblings, 0 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Noa Osherovich

testing.md describes the design behind the tests' infrastructure and
provides explanations for:
- How to run tests.
- How to control which tests to run and with which parameters.
- How to add tests.

Signed-off-by: Noa Osherovich <noaos@mellanox.com>
---
 Documentation/testing.md | 126 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 Documentation/testing.md

diff --git a/Documentation/testing.md b/Documentation/testing.md
new file mode 100644
index 000000000000..218dc36be478
--- /dev/null
+++ b/Documentation/testing.md
@@ -0,0 +1,126 @@
+# Testing in rdma-core
+
+rdma-core now offers an infrastructure for quick and easy additions of feature-
+specific tests.
+
+## Design
+### Resources Management
+`BaseResources` class is the basic objects aggregator available. It includes a
+Context and a PD.
+Inheriting from it is `TrafficResources` class, which also holds a MR, CQ and
+QP, making it enough to support loopback traffic testing. It exposes methods for
+creation of these objects which can be overridden by inheriting classes.
+Inheriting from `TrafficResources` are currently two class:
+- `RCResources`
+- `UDResources`
+
+Both add traffic-specific constants. `UDResources` for example overrides
+create_mr and adds the size of the GRH header to the message size. `RCResources`
+exposes a wrapper to modify the QP to RTS.
+
+### Tests-related Classes
+`unittest.TestCase` is a logical test unit in Python's unittest module.
+`RDMATestCase` inherits from it and adds the option to accept parameters
+(example will follow below) or use a random set of valid parameters:
+- If no device was provided, it iterates over the existing devices, for each
+  port of each device, it checks which GID indexes are valid (in RoCE, only
+  IPv4 and IPv6 based GIDs are used). Each <dev, port, gid> is added to an array
+  and one entry is selected.
+- If a device was provided, the same process is done for all ports of this
+  device, and so on.
+
+### Traffic Utilities
+tests/utils.py offers a few wrappers for common traffic operations, making the
+use of default values even shorter. Those traffic utilities accept an
+aggregation object as their first parameter and rely on that object to have
+valid RDMA resources for proper functioning.
+- get_[send, recv]_wr() creates a [Send, Recv]WR object with a single SGE. It
+  also sets the MR content to be 'c's for client side or 's's for server side
+  (this is later validated).
+- post_send() posts a single send request to the aggregation object's QP. If the
+  QP is a UD QP, an address vector will be added to the send WR.
+- post_recv() posts the given RecvWR <num> times, so it can be used to fill the
+  RQ prior to traffic as well as during traffic.
+- poll_cq() polls <num> completions from the CQ and raises an exception on a
+  non-success status.
+- validate() verifies that the data in the MR is as expected ('c's for server,
+  's's for client).
+- traffic() runs <num> iterations of send/recv between 2 players.
+
+## How to run rdma-core's tests
+The tests are not a Python package, as such they can be found under
+/usr/share/doc/rdma-core-{version}.
+In order to run all tests:
+```
+cd /usr/share/doc/rdma-core-26.0
+python3 run_tests.py
+```
+Output will be something like:
+```
+$ python3 run_tests.py
+..........................................ss...............
+----------------------------------------------------------------------
+Ran 59 tests in 13.268s
+
+OK (skipped=2)
+```
+A dot represents a passing test. 's' means a skipped test. 'E' means a test
+that failed.
+
+Tests can also be executed in verbose mode:
+```
+$ python3 run_tests.py -v
+test_create_ah (test_addr.AHTest) ... ok
+test_create_ah_roce (test_addr.AHTest) ... ok
+test_destroy_ah (test_addr.AHTest) ... ok
+test_create_comp_channel (test_cq.CCTest) ... ok
+< many more lines here>
+test_odp_rc_traffic (test_odp.OdpTestCase) ... skipped 'No dev/port/GID combinations, please check your setup and try again'
+test_odp_ud_traffic (test_odp.OdpTestCase) ... skipped 'No dev/port/GID combinations, please check your setup and try again'
+<more lines>
+
+----------------------------------------------------------------------
+Ran 59 tests in 12.857s
+
+OK (skipped=2)
+```
+Verbose mode provides the reason for skipping the test (if one was provided by
+the test developer).
+
+### Customized Execution
+tests/__init__.py defines a `load_tests` function that returns a
+unittest.TestSuite with the tests that will be executed.
+The default implementation collects all test_* methods from all the classes that
+inherit from `unittest.TestCase` (or `RDMATestCase`) and located in files under
+tests directory which names starts with test_.
+Users can replace that and create a suite that contains only a few selected
+tests:
+```
+suite = unittest.TestSuite()
+suite.addTest(RDMATestCase.parametrize(YourTestCase))
+```
+We're using 'parametrize' as it instantiates the TestCase for us.
+'parametrize' can accept arguments as well (device name, IB port, GID index and
+PKey index):
+```
+suite = unittest.TestSuite()
+suite.addTest(RDMATestCase.parametrize(YourTestCase, dev_name='devname'))
+```
+
+## Writing Tests
+The following section explains how to add a new test, using tests/test_odp.py
+as an example. It's a simple test that runs ping-pong over a few different
+traffic types.
+
+ODP requires capability check, so a decorator was added to tests/utils.py.
+The first change for ODP execution is when registering a memory region (need to
+set the ON_DEMAND access flag), so we do as follows:
+1. Create the players by inheriting from `RCResources` (for RC traffic).
+2. In the player, override create_mr() and add the decorator to it. It will run
+   before the actual call to ibv_reg_mr and if ODP caps are off, the test will
+   be skipped.
+ 3. Create the `OdpTestCase` by inheriting from `RDMATestCase`.
+ 4. In the test case, add a method starting with test_, to let the unittest
+    infrastructure that this is a test.
+ 5. In the test method, create the players (which already check the ODP caps)
+    and call the traffic() function, providing it the two players.
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH rdma-core 14/14] tests: Unify API tests' output
  2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
                   ` (12 preceding siblings ...)
  2019-08-19  6:58 ` [PATCH rdma-core 13/14] Documentation: Add background for rdma-core tests Noa Osherovich
@ 2019-08-19  6:58 ` Noa Osherovich
  13 siblings, 0 replies; 26+ messages in thread
From: Noa Osherovich @ 2019-08-19  6:58 UTC (permalink / raw)
  To: dledford, jgg, leonro; +Cc: linux-rdma, Noa Osherovich

When executed in verbose mode, unittest infrastructure prints a test's
docstring if it's in a single line format, which was used in some
tests. Change those to use multiline format instead.

Signed-off-by: Noa Osherovich <noaos@mellanox.com>
---
 tests/test_device.py |  6 ++++--
 tests/test_mr.py     | 36 +++++++++++++++++++++++++++---------
 2 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/tests/test_device.py b/tests/test_device.py
index e395e793c28f..32dedb34d559 100644
--- a/tests/test_device.py
+++ b/tests/test_device.py
@@ -120,7 +120,9 @@ class DeviceTest(unittest.TestCase):
 
     @staticmethod
     def test_query_port_bad_flow():
-        """ Verify that querying non-existing ports fails as expected """
+        """
+        Verify that querying non-existing ports fails as expected
+        """
         lst = d.get_device_list()
         for dev in lst:
             with d.Context(name=dev.name.decode()) as ctx:
@@ -199,7 +201,7 @@ class DMTest(PyverbsAPITestCase):
 
     def test_destroy_dm_bad_flow(self):
         """
-        test calling ibv_free_dm() twice
+        Test calling ibv_free_dm() twice
         """
         for ctx, attr, attr_ex in self.devices:
             if attr_ex.max_dm_size == 0:
diff --git a/tests/test_mr.py b/tests/test_mr.py
index e87fb33624ed..d11a4b8f8f26 100644
--- a/tests/test_mr.py
+++ b/tests/test_mr.py
@@ -32,7 +32,9 @@ class MRTest(PyverbsAPITestCase):
                         pass
 
     def test_dereg_mr(self):
-        """ Test ibv_dereg_mr() """
+        """
+        Test ibv_dereg_mr()
+        """
         for ctx, attr, attr_ex in self.devices:
             with PD(ctx) as pd:
                 flags = u.get_access_flags(ctx)
@@ -42,7 +44,9 @@ class MRTest(PyverbsAPITestCase):
 
     @staticmethod
     def test_reg_mr_bad_flow():
-        """ Verify that trying to register a MR with None PD fails """
+        """
+        Verify that trying to register a MR with None PD fails
+        """
         try:
             # Use the simplest access flags necessary
             MR(None, random.randint(0, 10000), e.IBV_ACCESS_LOCAL_WRITE)
@@ -53,7 +57,9 @@ class MRTest(PyverbsAPITestCase):
             raise PyverbsRDMAErrno('Created a MR with None PD')
 
     def test_dereg_mr_twice(self):
-        """ Verify that explicit call to MR's close() doesn't fails """
+        """
+        Verify that explicit call to MR's close() doesn't fail
+        """
         for ctx, attr, attr_ex in self.devices:
             with PD(ctx) as pd:
                 flags = u.get_access_flags(ctx)
@@ -65,7 +71,9 @@ class MRTest(PyverbsAPITestCase):
                         mr.close()
 
     def test_reg_mr_bad_flags(self):
-        """ Verify that illegal flags combination fails as expected """
+        """
+        Verify that illegal flags combination fails as expected
+        """
         for ctx, attr, attr_ex in self.devices:
             with PD(ctx) as pd:
                 for i in range(5):
@@ -159,35 +167,45 @@ class MWTest(PyverbsAPITestCase):
     Test various functionalities of the MW class.
     """
     def test_reg_mw_type1(self):
-        """ Test ibv_alloc_mw() """
+        """
+        Test ibv_alloc_mw() for type 1 MW
+        """
         for ctx, attr, attr_ex in self.devices:
             with PD(ctx) as pd:
                 with MW(pd, e.IBV_MW_TYPE_1):
                     pass
 
     def test_reg_mw_type2(self):
-        """ Test ibv_alloc_mw() """
+        """
+        Test ibv_alloc_mw() for type 2 MW
+        """
         for ctx, attr, attr_ex in self.devices:
             with PD(ctx) as pd:
                 with MW(pd, e.IBV_MW_TYPE_2):
                     pass
 
     def test_dereg_mw_type1(self):
-        """ Test ibv_dealloc_mw() """
+        """
+        Test ibv_dealloc_mw() for type 1 MW
+        """
         for ctx, attr, attr_ex in self.devices:
             with PD(ctx) as pd:
                 with MW(pd, e.IBV_MW_TYPE_1) as mw:
                     mw.close()
 
     def test_dereg_mw_type2(self):
-        """ Test ibv_dealloc_mw() """
+        """
+        Test ibv_dealloc_mw() for type 2 MW
+        """
         for ctx, attr, attr_ex in self.devices:
             with PD(ctx) as pd:
                 with MW(pd, e.IBV_MW_TYPE_2) as mw:
                     mw.close()
 
     def test_reg_mw_wrong_type(self):
-        """ Test ibv_alloc_mw() """
+        """
+        Verify that trying to create a MW of a wrong type fails
+        """
         for ctx, attr, attr_ex in self.devices:
             with PD(ctx) as pd:
                 try:
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build
  2019-08-19  6:58 ` [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build Noa Osherovich
@ 2019-08-19 13:50   ` Jason Gunthorpe
  2019-08-20 13:00     ` Noa Osherovich
  0 siblings, 1 reply; 26+ messages in thread
From: Jason Gunthorpe @ 2019-08-19 13:50 UTC (permalink / raw)
  To: Noa Osherovich; +Cc: dledford, Leon Romanovsky, linux-rdma

On Mon, Aug 19, 2019 at 09:58:16AM +0300, Noa Osherovich wrote:
> Have the tests installed separately from pyverbs as they're not a
> part of the package. They will now be placed under
> /usr/share/doc/rdma-core-{version}/tests.
> The tests can be executed as follows:
> python3 /usr/share/doc/rdma-core-{version}/run_tests.py
> 
> Signed-off-by: Noa Osherovich <noaos@mellanox.com>
>  CMakeLists.txt                       | 11 +++++++++++
>  buildlib/pyverbs_functions.cmake     |  7 +++++++
>  debian/python3-pyverbs.install       |  2 ++
>  pyverbs/CMakeLists.txt               | 17 -----------------
>  redhat/rdma-core.spec                |  2 ++
>  pyverbs/run_tests.py => run_tests.py |  0

I'd prefer run_tests to be in the tests directory..

Jason

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build
  2019-08-19 13:50   ` Jason Gunthorpe
@ 2019-08-20 13:00     ` Noa Osherovich
  2019-08-22 16:18       ` Leon Romanovsky
  0 siblings, 1 reply; 26+ messages in thread
From: Noa Osherovich @ 2019-08-20 13:00 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: dledford, Leon Romanovsky, linux-rdma

On 8/19/2019 4:50 PM, Jason Gunthorpe wrote:

> I'd prefer run_tests to be in the tests directory..
>
> Jason

PR was updated

Thanks,
Noa


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build
  2019-08-20 13:00     ` Noa Osherovich
@ 2019-08-22 16:18       ` Leon Romanovsky
  2019-08-22 16:52         ` Jason Gunthorpe
  0 siblings, 1 reply; 26+ messages in thread
From: Leon Romanovsky @ 2019-08-22 16:18 UTC (permalink / raw)
  To: Noa Osherovich; +Cc: Jason Gunthorpe, dledford, linux-rdma

On Tue, Aug 20, 2019 at 01:00:47PM +0000, Noa Osherovich wrote:
> On 8/19/2019 4:50 PM, Jason Gunthorpe wrote:
>
> > I'd prefer run_tests to be in the tests directory..
> >
> > Jason
>
> PR was updated

1.
IMHO, run_tests.py should be placed inside tests directory too and not
only installed into tests/.

➜  rdma-core git:(noaos-pr-tests) ✗ pwd
/images/leonro/src/rdma-core
➜  rdma-core git:(noaos-pr-tests) ✗ ls -al | grep  run_tests.py
-rw-rw-r--.  1 leonro leonro   549 Aug 22 18:59 run_tests.py

Expected
➜  rdma-core git:(noaos-pr-tests) ✗ ls -al tests/ | grep  run_tests.py
-rw-rw-r--.  1 leonro leonro   549 Aug 22 18:59 run_tests.py

2.
Execution of run_tests.py produces a lot of untracked filed
➜  rdma-core git:(noaos-pr-tests) ✗ git st
On branch noaos-pr-tests
Untracked files:
  (use "git add <file>..." to include in what will be committed)

	pyverbs/__init__.pyc
	pyverbs/pyverbs_error.pyc
	tests/__init__.pyc
	tests/base.pyc
	tests/test_addr.pyc
	tests/test_cq.pyc
	tests/test_device.pyc
	tests/test_mr.pyc
	tests/test_odp.pyc
	tests/test_pd.pyc
	tests/test_qp.pyc

3. run_tests.py lacks of python3 shebang
4. Attempt to run on system without ib* modules causes to awful splat.
Is it expected?
t:(noaos-pr-tests) python ./run_tests.py
EEEEEEE
======================================================================
ERROR: test_mr (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_mr
Traceback (most recent call last):
  File "/usr/lib64/python2.7/unittest/loader.py", line 254, in   _find_tests
    module = self._get_module_from_name(name)
  File "/usr/lib64/python2.7/unittest/loader.py", line 232, in _get_module_from_name
    __import__(name)
  File "/images/leonro/src/rdma-core/tests/test_mr.py", line 10, in <module>
    from tests.base import PyverbsAPITestCase
  File "/images/leonro/src/rdma-core/tests/base.py", line 7, in <module>
    from pyverbs.qp import QPCap, QPInitAttr, QPAttr, QP
ImportError: No module named qp

.....

----------------------------------------------------------------------
Ran 7 tests in 0.000s

FAILED (errors=7)

Thanks

>
> Thanks,
> Noa
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build
  2019-08-22 16:18       ` Leon Romanovsky
@ 2019-08-22 16:52         ` Jason Gunthorpe
  2019-09-01 13:30           ` Noa Osherovich
  0 siblings, 1 reply; 26+ messages in thread
From: Jason Gunthorpe @ 2019-08-22 16:52 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: Noa Osherovich, dledford, linux-rdma

On Thu, Aug 22, 2019 at 01:18:24PM -0300, Leon Romanovsky wrote:
> On Tue, Aug 20, 2019 at 01:00:47PM +0000, Noa Osherovich wrote:
> > On 8/19/2019 4:50 PM, Jason Gunthorpe wrote:
> >
> > > I'd prefer run_tests to be in the tests directory..
> > >
> > > Jason
> >
> > PR was updated
> 
> 1.
> IMHO, run_tests.py should be placed inside tests directory too and not
> only installed into tests/.

Yes, this is what I ment. The file should be in tests/ and it should
be built into build/bin, and installed into the examples


> 2.
> Execution of run_tests.py produces a lot of untracked filed
> ➜  rdma-core git:(noaos-pr-tests) ✗ git st
> On branch noaos-pr-tests
> Untracked files:
>   (use "git add <file>..." to include in what will be committed)
> 
> 	pyverbs/__init__.pyc
> 	pyverbs/pyverbs_error.pyc
> 	tests/__init__.pyc
> 	tests/base.pyc
> 	tests/test_addr.pyc
> 	tests/test_cq.pyc
> 	tests/test_device.pyc
> 	tests/test_mr.pyc
> 	tests/test_odp.pyc
> 	tests/test_pd.pyc
> 	tests/test_qp.pyc

*.pyc will have to be added to the .gitignore

> 3. run_tests.py lacks of python3 shebang

Originally it was not installed, so this was fine, as the build/bin
script does all the required setup, however now that it is to be
installed it should have the #! - and it should also work without any
trouble from it's example location.

Jason

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build
  2019-08-22 16:52         ` Jason Gunthorpe
@ 2019-09-01 13:30           ` Noa Osherovich
  2019-09-09 10:29             ` Leon Romanovsky
  0 siblings, 1 reply; 26+ messages in thread
From: Noa Osherovich @ 2019-09-01 13:30 UTC (permalink / raw)
  To: Jason Gunthorpe, Leon Romanovsky; +Cc: dledford, linux-rdma

On 8/22/2019 7:52 PM, Jason Gunthorpe wrote:

> On Thu, Aug 22, 2019 at 01:18:24PM -0300, Leon Romanovsky wrote:
>> On Tue, Aug 20, 2019 at 01:00:47PM +0000, Noa Osherovich wrote:
>>> On 8/19/2019 4:50 PM, Jason Gunthorpe wrote:
>>>
>>>> I'd prefer run_tests to be in the tests directory..
>>>>
>>>> Jason
>>> PR was updated
>> 1.
>> IMHO, run_tests.py should be placed inside tests directory too and not
>> only installed into tests/.
> Yes, this is what I ment. The file should be in tests/ and it should
> be built into build/bin, and installed into the examples
>> 2.
>> Execution of run_tests.py produces a lot of untracked filed
>> ➜  rdma-core git:(noaos-pr-tests) ✗ git st
>> On branch noaos-pr-tests
>> Untracked files:
>>   (use "git add <file>..." to include in what will be committed)
>>
>> 	pyverbs/__init__.pyc
>> 	pyverbs/pyverbs_error.pyc
>> 	tests/__init__.pyc
>> 	tests/base.pyc
>> 	tests/test_addr.pyc
>> 	tests/test_cq.pyc
>> 	tests/test_device.pyc
>> 	tests/test_mr.pyc
>> 	tests/test_odp.pyc
>> 	tests/test_pd.pyc
>> 	tests/test_qp.pyc
> *.pyc will have to be added to the .gitignore
>> 3. run_tests.py lacks of python3 shebang
> Originally it was not installed, so this was fine, as the build/bin
> script does all the required setup, however now that it is to be
> installed it should have the #! - and it should also work without any
> trouble from it's example location.
>
> Jason

PR was updated.

Thanks,

Noa


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build
  2019-09-01 13:30           ` Noa Osherovich
@ 2019-09-09 10:29             ` Leon Romanovsky
  2019-09-09 10:39               ` Noa Osherovich
  0 siblings, 1 reply; 26+ messages in thread
From: Leon Romanovsky @ 2019-09-09 10:29 UTC (permalink / raw)
  To: Noa Osherovich; +Cc: Jason Gunthorpe, dledford, linux-rdma

On Sun, Sep 01, 2019 at 01:30:56PM +0000, Noa Osherovich wrote:
> On 8/22/2019 7:52 PM, Jason Gunthorpe wrote:
>
> > On Thu, Aug 22, 2019 at 01:18:24PM -0300, Leon Romanovsky wrote:
> >> On Tue, Aug 20, 2019 at 01:00:47PM +0000, Noa Osherovich wrote:
> >>> On 8/19/2019 4:50 PM, Jason Gunthorpe wrote:
> >>>
> >>>> I'd prefer run_tests to be in the tests directory..
> >>>>
> >>>> Jason
> >>> PR was updated
> >> 1.
> >> IMHO, run_tests.py should be placed inside tests directory too and not
> >> only installed into tests/.
> > Yes, this is what I ment. The file should be in tests/ and it should
> > be built into build/bin, and installed into the examples
> >> 2.
> >> Execution of run_tests.py produces a lot of untracked filed
> >> ➜  rdma-core git:(noaos-pr-tests) ✗ git st
> >> On branch noaos-pr-tests
> >> Untracked files:
> >>   (use "git add <file>..." to include in what will be committed)
> >>
> >> 	pyverbs/__init__.pyc
> >> 	pyverbs/pyverbs_error.pyc
> >> 	tests/__init__.pyc
> >> 	tests/base.pyc
> >> 	tests/test_addr.pyc
> >> 	tests/test_cq.pyc
> >> 	tests/test_device.pyc
> >> 	tests/test_mr.pyc
> >> 	tests/test_odp.pyc
> >> 	tests/test_pd.pyc
> >> 	tests/test_qp.pyc
> > *.pyc will have to be added to the .gitignore
> >> 3. run_tests.py lacks of python3 shebang
> > Originally it was not installed, so this was fine, as the build/bin
> > script does all the required setup, however now that it is to be
> > installed it should have the #! - and it should also work without any
> > trouble from it's example location.
> >
> > Jason
>
> PR was updated.

I tried it now and got very confusing results.

On my machine there are no ib_devices, and I expected to see ALL tests
marked as skipped, but got two skipped only, is it expected behaviour?

_  rdma-core git:(noaos-pr-tests) ./build/bin/run_tests.py
..........................................ss...............
----------------------------------------------------------------------
Ran 59 tests in 0.004s

OK (skipped=2)

Thanks

>
> Thanks,
>
> Noa
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build
  2019-09-09 10:29             ` Leon Romanovsky
@ 2019-09-09 10:39               ` Noa Osherovich
  2019-09-09 11:26                 ` Leon Romanovsky
  0 siblings, 1 reply; 26+ messages in thread
From: Noa Osherovich @ 2019-09-09 10:39 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: Jason Gunthorpe, dledford, linux-rdma


On 9/9/2019 1:29 PM, Leon Romanovsky wrote:
> On Sun, Sep 01, 2019 at 01:30:56PM +0000, Noa Osherovich wrote:
>> On 8/22/2019 7:52 PM, Jason Gunthorpe wrote:
>>
>>> On Thu, Aug 22, 2019 at 01:18:24PM -0300, Leon Romanovsky wrote:
>>>> On Tue, Aug 20, 2019 at 01:00:47PM +0000, Noa Osherovich wrote:
>>>>> On 8/19/2019 4:50 PM, Jason Gunthorpe wrote:
>>>>>
>>>>>> I'd prefer run_tests to be in the tests directory..
>>>>>>
>>>>>> Jason
>>>>> PR was updated
>>>> 1.
>>>> IMHO, run_tests.py should be placed inside tests directory too and not
>>>> only installed into tests/.
>>> Yes, this is what I ment. The file should be in tests/ and it should
>>> be built into build/bin, and installed into the examples
>>>> 2.
>>>> Execution of run_tests.py produces a lot of untracked filed
>>>> ➜  rdma-core git:(noaos-pr-tests) ✗ git st
>>>> On branch noaos-pr-tests
>>>> Untracked files:
>>>>   (use "git add <file>..." to include in what will be committed)
>>>>
>>>> 	pyverbs/__init__.pyc
>>>> 	pyverbs/pyverbs_error.pyc
>>>> 	tests/__init__.pyc
>>>> 	tests/base.pyc
>>>> 	tests/test_addr.pyc
>>>> 	tests/test_cq.pyc
>>>> 	tests/test_device.pyc
>>>> 	tests/test_mr.pyc
>>>> 	tests/test_odp.pyc
>>>> 	tests/test_pd.pyc
>>>> 	tests/test_qp.pyc
>>> *.pyc will have to be added to the .gitignore
>>>> 3. run_tests.py lacks of python3 shebang
>>> Originally it was not installed, so this was fine, as the build/bin
>>> script does all the required setup, however now that it is to be
>>> installed it should have the #! - and it should also work without any
>>> trouble from it's example location.
>>>
>>> Jason
>> PR was updated.
> I tried it now and got very confusing results.
>
> On my machine there are no ib_devices, and I expected to see ALL tests
> marked as skipped, but got two skipped only, is it expected behaviour?

Yes. If you recall, our previous unittests worked differently than the new ones; each
test would iterate over an array of all available devices and would run on each device.
The array can be of length 0. If no failure was found, they're marked as passed.
The new tests skip (the reported 's' you saw) in case a combination of device/port/GID
index wasn't found.

Thanks,
Noa

>
> _  rdma-core git:(noaos-pr-tests) ./build/bin/run_tests.py
> ..........................................ss...............
> ----------------------------------------------------------------------
> Ran 59 tests in 0.004s
>
> OK (skipped=2)
>
> Thanks
>
>> Thanks,
>>
>> Noa
>>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build
  2019-09-09 10:39               ` Noa Osherovich
@ 2019-09-09 11:26                 ` Leon Romanovsky
  2019-09-09 11:30                   ` Noa Osherovich
  2019-09-09 11:34                   ` Leon Romanovsky
  0 siblings, 2 replies; 26+ messages in thread
From: Leon Romanovsky @ 2019-09-09 11:26 UTC (permalink / raw)
  To: Noa Osherovich; +Cc: Jason Gunthorpe, dledford, linux-rdma

On Mon, Sep 09, 2019 at 10:39:44AM +0000, Noa Osherovich wrote:
>
> On 9/9/2019 1:29 PM, Leon Romanovsky wrote:
> > On Sun, Sep 01, 2019 at 01:30:56PM +0000, Noa Osherovich wrote:
> >> On 8/22/2019 7:52 PM, Jason Gunthorpe wrote:
> >>
> >>> On Thu, Aug 22, 2019 at 01:18:24PM -0300, Leon Romanovsky wrote:
> >>>> On Tue, Aug 20, 2019 at 01:00:47PM +0000, Noa Osherovich wrote:
> >>>>> On 8/19/2019 4:50 PM, Jason Gunthorpe wrote:
> >>>>>
> >>>>>> I'd prefer run_tests to be in the tests directory..
> >>>>>>
> >>>>>> Jason
> >>>>> PR was updated
> >>>> 1.
> >>>> IMHO, run_tests.py should be placed inside tests directory too and not
> >>>> only installed into tests/.
> >>> Yes, this is what I ment. The file should be in tests/ and it should
> >>> be built into build/bin, and installed into the examples
> >>>> 2.
> >>>> Execution of run_tests.py produces a lot of untracked filed
> >>>> ➜  rdma-core git:(noaos-pr-tests) ✗ git st
> >>>> On branch noaos-pr-tests
> >>>> Untracked files:
> >>>>   (use "git add <file>..." to include in what will be committed)
> >>>>
> >>>> 	pyverbs/__init__.pyc
> >>>> 	pyverbs/pyverbs_error.pyc
> >>>> 	tests/__init__.pyc
> >>>> 	tests/base.pyc
> >>>> 	tests/test_addr.pyc
> >>>> 	tests/test_cq.pyc
> >>>> 	tests/test_device.pyc
> >>>> 	tests/test_mr.pyc
> >>>> 	tests/test_odp.pyc
> >>>> 	tests/test_pd.pyc
> >>>> 	tests/test_qp.pyc
> >>> *.pyc will have to be added to the .gitignore
> >>>> 3. run_tests.py lacks of python3 shebang
> >>> Originally it was not installed, so this was fine, as the build/bin
> >>> script does all the required setup, however now that it is to be
> >>> installed it should have the #! - and it should also work without any
> >>> trouble from it's example location.
> >>>
> >>> Jason
> >> PR was updated.
> > I tried it now and got very confusing results.
> >
> > On my machine there are no ib_devices, and I expected to see ALL tests
> > marked as skipped, but got two skipped only, is it expected behaviour?
>
> Yes. If you recall, our previous unittests worked differently than the new ones; each
> test would iterate over an array of all available devices and would run on each device.
> The array can be of length 0. If no failure was found, they're marked as passed.
> The new tests skip (the reported 's' you saw) in case a combination of device/port/GID
> index wasn't found.

array length 0 should return "skipped" and not "passed".

Thanks

>
> Thanks,
> Noa
>
> >
> > _  rdma-core git:(noaos-pr-tests) ./build/bin/run_tests.py
> > ..........................................ss...............
> > ----------------------------------------------------------------------
> > Ran 59 tests in 0.004s
> >
> > OK (skipped=2)
> >
> > Thanks
> >
> >> Thanks,
> >>
> >> Noa
> >>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build
  2019-09-09 11:26                 ` Leon Romanovsky
@ 2019-09-09 11:30                   ` Noa Osherovich
  2019-09-09 11:38                     ` Leon Romanovsky
  2019-09-09 11:34                   ` Leon Romanovsky
  1 sibling, 1 reply; 26+ messages in thread
From: Noa Osherovich @ 2019-09-09 11:30 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: Jason Gunthorpe, dledford, linux-rdma


On 9/9/2019 2:26 PM, Leon Romanovsky wrote:
> On Mon, Sep 09, 2019 at 10:39:44AM +0000, Noa Osherovich wrote:
>> On 9/9/2019 1:29 PM, Leon Romanovsky wrote:
>>> On Sun, Sep 01, 2019 at 01:30:56PM +0000, Noa Osherovich wrote:
>>>> On 8/22/2019 7:52 PM, Jason Gunthorpe wrote:
>>>>
>>>>> On Thu, Aug 22, 2019 at 01:18:24PM -0300, Leon Romanovsky wrote:
>>>>>> On Tue, Aug 20, 2019 at 01:00:47PM +0000, Noa Osherovich wrote:
>>>>>>> On 8/19/2019 4:50 PM, Jason Gunthorpe wrote:
>>>>>>>
>>>>>>>> I'd prefer run_tests to be in the tests directory..
>>>>>>>>
>>>>>>>> Jason
>>>>>>> PR was updated
>>>>>> 1.
>>>>>> IMHO, run_tests.py should be placed inside tests directory too and not
>>>>>> only installed into tests/.
>>>>> Yes, this is what I ment. The file should be in tests/ and it should
>>>>> be built into build/bin, and installed into the examples
>>>>>> 2.
>>>>>> Execution of run_tests.py produces a lot of untracked filed
>>>>>> ➜  rdma-core git:(noaos-pr-tests) ✗ git st
>>>>>> On branch noaos-pr-tests
>>>>>> Untracked files:
>>>>>>   (use "git add <file>..." to include in what will be committed)
>>>>>>
>>>>>> 	pyverbs/__init__.pyc
>>>>>> 	pyverbs/pyverbs_error.pyc
>>>>>> 	tests/__init__.pyc
>>>>>> 	tests/base.pyc
>>>>>> 	tests/test_addr.pyc
>>>>>> 	tests/test_cq.pyc
>>>>>> 	tests/test_device.pyc
>>>>>> 	tests/test_mr.pyc
>>>>>> 	tests/test_odp.pyc
>>>>>> 	tests/test_pd.pyc
>>>>>> 	tests/test_qp.pyc
>>>>> *.pyc will have to be added to the .gitignore
>>>>>> 3. run_tests.py lacks of python3 shebang
>>>>> Originally it was not installed, so this was fine, as the build/bin
>>>>> script does all the required setup, however now that it is to be
>>>>> installed it should have the #! - and it should also work without any
>>>>> trouble from it's example location.
>>>>>
>>>>> Jason
>>>> PR was updated.
>>> I tried it now and got very confusing results.
>>>
>>> On my machine there are no ib_devices, and I expected to see ALL tests
>>> marked as skipped, but got two skipped only, is it expected behaviour?
>> Yes. If you recall, our previous unittests worked differently than the new ones; each
>> test would iterate over an array of all available devices and would run on each device.
>> The array can be of length 0. If no failure was found, they're marked as passed.
>> The new tests skip (the reported 's' you saw) in case a combination of device/port/GID
>> index wasn't found.
> array length 0 should return "skipped" and not "passed".
>
> Thanks

Leon, these are older tests, not related to the current PR.
I can update their behavior, but let's separate it from the PR.

Thanks,
Noa

>> Thanks,
>> Noa
>>
>>> _  rdma-core git:(noaos-pr-tests) ./build/bin/run_tests.py
>>> ..........................................ss...............
>>> ----------------------------------------------------------------------
>>> Ran 59 tests in 0.004s
>>>
>>> OK (skipped=2)
>>>
>>> Thanks
>>>
>>>> Thanks,
>>>>
>>>> Noa
>>>>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build
  2019-09-09 11:26                 ` Leon Romanovsky
  2019-09-09 11:30                   ` Noa Osherovich
@ 2019-09-09 11:34                   ` Leon Romanovsky
  1 sibling, 0 replies; 26+ messages in thread
From: Leon Romanovsky @ 2019-09-09 11:34 UTC (permalink / raw)
  To: Noa Osherovich; +Cc: Jason Gunthorpe, dledford, linux-rdma

On Mon, Sep 09, 2019 at 11:26:35AM +0000, Leon Romanovsky wrote:
> On Mon, Sep 09, 2019 at 10:39:44AM +0000, Noa Osherovich wrote:
> >
> > On 9/9/2019 1:29 PM, Leon Romanovsky wrote:
> > > On Sun, Sep 01, 2019 at 01:30:56PM +0000, Noa Osherovich wrote:
> > >> On 8/22/2019 7:52 PM, Jason Gunthorpe wrote:
> > >>
> > >>> On Thu, Aug 22, 2019 at 01:18:24PM -0300, Leon Romanovsky wrote:
> > >>>> On Tue, Aug 20, 2019 at 01:00:47PM +0000, Noa Osherovich wrote:
> > >>>>> On 8/19/2019 4:50 PM, Jason Gunthorpe wrote:
> > >>>>>
> > >>>>>> I'd prefer run_tests to be in the tests directory..
> > >>>>>>
> > >>>>>> Jason
> > >>>>> PR was updated
> > >>>> 1.
> > >>>> IMHO, run_tests.py should be placed inside tests directory too and not
> > >>>> only installed into tests/.
> > >>> Yes, this is what I ment. The file should be in tests/ and it should
> > >>> be built into build/bin, and installed into the examples
> > >>>> 2.
> > >>>> Execution of run_tests.py produces a lot of untracked filed
> > >>>> ➜  rdma-core git:(noaos-pr-tests) ✗ git st
> > >>>> On branch noaos-pr-tests
> > >>>> Untracked files:
> > >>>>   (use "git add <file>..." to include in what will be committed)
> > >>>>
> > >>>> 	pyverbs/__init__.pyc
> > >>>> 	pyverbs/pyverbs_error.pyc
> > >>>> 	tests/__init__.pyc
> > >>>> 	tests/base.pyc
> > >>>> 	tests/test_addr.pyc
> > >>>> 	tests/test_cq.pyc
> > >>>> 	tests/test_device.pyc
> > >>>> 	tests/test_mr.pyc
> > >>>> 	tests/test_odp.pyc
> > >>>> 	tests/test_pd.pyc
> > >>>> 	tests/test_qp.pyc
> > >>> *.pyc will have to be added to the .gitignore
> > >>>> 3. run_tests.py lacks of python3 shebang
> > >>> Originally it was not installed, so this was fine, as the build/bin
> > >>> script does all the required setup, however now that it is to be
> > >>> installed it should have the #! - and it should also work without any
> > >>> trouble from it's example location.
> > >>>
> > >>> Jason
> > >> PR was updated.
> > > I tried it now and got very confusing results.
> > >
> > > On my machine there are no ib_devices, and I expected to see ALL tests
> > > marked as skipped, but got two skipped only, is it expected behaviour?
> >
> > Yes. If you recall, our previous unittests worked differently than the new ones; each
> > test would iterate over an array of all available devices and would run on each device.
> > The array can be of length 0. If no failure was found, they're marked as passed.
> > The new tests skip (the reported 's' you saw) in case a combination of device/port/GID
> > index wasn't found.
>
> array length 0 should return "skipped" and not "passed".

I run over IB device over rdma-next and get very exciting splat.

[leonro@server ~]$
/images/leonro/src/rdma-core/build/bin/run_tests.py
.....EFE..................................ss...............
======================================================================
ERROR: test_create_cq_ex (test_cq.CQEXTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/images/leonro/src/rdma-core/tests/test_cq.py", line 118, in test_create_cq_ex
      with CQEX(ctx, get_attrs_ex(attr, attr_ex)):
  File "cq.pyx", line 264, in pyverbs.cq.CQEX.__cinit__
pyverbs.pyverbs_error.PyverbsRDMAError: Failed to create extended CQ. Errno: 95, Operation not supported

and many more.

>
> Thanks
>
> >
> > Thanks,
> > Noa
> >
> > >
> > > _  rdma-core git:(noaos-pr-tests) ./build/bin/run_tests.py
> > > ..........................................ss...............
> > > ----------------------------------------------------------------------
> > > Ran 59 tests in 0.004s
> > >
> > > OK (skipped=2)
> > >
> > > Thanks
> > >
> > >> Thanks,
> > >>
> > >> Noa
> > >>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build
  2019-09-09 11:30                   ` Noa Osherovich
@ 2019-09-09 11:38                     ` Leon Romanovsky
  0 siblings, 0 replies; 26+ messages in thread
From: Leon Romanovsky @ 2019-09-09 11:38 UTC (permalink / raw)
  To: Noa Osherovich; +Cc: Jason Gunthorpe, dledford, linux-rdma

On Mon, Sep 09, 2019 at 11:30:07AM +0000, Noa Osherovich wrote:
>
> On 9/9/2019 2:26 PM, Leon Romanovsky wrote:
> > On Mon, Sep 09, 2019 at 10:39:44AM +0000, Noa Osherovich wrote:
> >> On 9/9/2019 1:29 PM, Leon Romanovsky wrote:
> >>> On Sun, Sep 01, 2019 at 01:30:56PM +0000, Noa Osherovich wrote:
> >>>> On 8/22/2019 7:52 PM, Jason Gunthorpe wrote:
> >>>>
> >>>>> On Thu, Aug 22, 2019 at 01:18:24PM -0300, Leon Romanovsky wrote:
> >>>>>> On Tue, Aug 20, 2019 at 01:00:47PM +0000, Noa Osherovich wrote:
> >>>>>>> On 8/19/2019 4:50 PM, Jason Gunthorpe wrote:
> >>>>>>>
> >>>>>>>> I'd prefer run_tests to be in the tests directory..
> >>>>>>>>
> >>>>>>>> Jason
> >>>>>>> PR was updated
> >>>>>> 1.
> >>>>>> IMHO, run_tests.py should be placed inside tests directory too and not
> >>>>>> only installed into tests/.
> >>>>> Yes, this is what I ment. The file should be in tests/ and it should
> >>>>> be built into build/bin, and installed into the examples
> >>>>>> 2.
> >>>>>> Execution of run_tests.py produces a lot of untracked filed
> >>>>>> ➜  rdma-core git:(noaos-pr-tests) ✗ git st
> >>>>>> On branch noaos-pr-tests
> >>>>>> Untracked files:
> >>>>>>   (use "git add <file>..." to include in what will be committed)
> >>>>>>
> >>>>>> 	pyverbs/__init__.pyc
> >>>>>> 	pyverbs/pyverbs_error.pyc
> >>>>>> 	tests/__init__.pyc
> >>>>>> 	tests/base.pyc
> >>>>>> 	tests/test_addr.pyc
> >>>>>> 	tests/test_cq.pyc
> >>>>>> 	tests/test_device.pyc
> >>>>>> 	tests/test_mr.pyc
> >>>>>> 	tests/test_odp.pyc
> >>>>>> 	tests/test_pd.pyc
> >>>>>> 	tests/test_qp.pyc
> >>>>> *.pyc will have to be added to the .gitignore
> >>>>>> 3. run_tests.py lacks of python3 shebang
> >>>>> Originally it was not installed, so this was fine, as the build/bin
> >>>>> script does all the required setup, however now that it is to be
> >>>>> installed it should have the #! - and it should also work without any
> >>>>> trouble from it's example location.
> >>>>>
> >>>>> Jason
> >>>> PR was updated.
> >>> I tried it now and got very confusing results.
> >>>
> >>> On my machine there are no ib_devices, and I expected to see ALL tests
> >>> marked as skipped, but got two skipped only, is it expected behaviour?
> >> Yes. If you recall, our previous unittests worked differently than the new ones; each
> >> test would iterate over an array of all available devices and would run on each device.
> >> The array can be of length 0. If no failure was found, they're marked as passed.
> >> The new tests skip (the reported 's' you saw) in case a combination of device/port/GID
> >> index wasn't found.
> > array length 0 should return "skipped" and not "passed".
> >
> > Thanks
>
> Leon, these are older tests, not related to the current PR.
> I can update their behavior, but let's separate it from the PR.

Great, please update.

Thanks

>
> Thanks,
> Noa
>
> >> Thanks,
> >> Noa
> >>
> >>> _  rdma-core git:(noaos-pr-tests) ./build/bin/run_tests.py
> >>> ..........................................ss...............
> >>> ----------------------------------------------------------------------
> >>> Ran 59 tests in 0.004s
> >>>
> >>> OK (skipped=2)
> >>>
> >>> Thanks
> >>>
> >>>> Thanks,
> >>>>
> >>>> Noa
> >>>>

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2019-09-09 11:38 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19  6:58 [PATCH rdma-core 00/14] rdma-core tests infrastructure Noa Osherovich
2019-08-19  6:58 ` [PATCH rdma-core 01/14] pyverbs/tests: Rename base class Noa Osherovich
2019-08-19  6:58 ` [PATCH rdma-core 02/14] pyverbs: Move tests to a stand-alone directory Noa Osherovich
2019-08-19  6:58 ` [PATCH rdma-core 03/14] build: Add pyverbs-based test to the build Noa Osherovich
2019-08-19 13:50   ` Jason Gunthorpe
2019-08-20 13:00     ` Noa Osherovich
2019-08-22 16:18       ` Leon Romanovsky
2019-08-22 16:52         ` Jason Gunthorpe
2019-09-01 13:30           ` Noa Osherovich
2019-09-09 10:29             ` Leon Romanovsky
2019-09-09 10:39               ` Noa Osherovich
2019-09-09 11:26                 ` Leon Romanovsky
2019-09-09 11:30                   ` Noa Osherovich
2019-09-09 11:38                     ` Leon Romanovsky
2019-09-09 11:34                   ` Leon Romanovsky
2019-08-19  6:58 ` [PATCH rdma-core 04/14] tests: BaseResources Class Noa Osherovich
2019-08-19  6:58 ` [PATCH rdma-core 05/14] tests: RDMATestCase Noa Osherovich
2019-08-19  6:58 ` [PATCH rdma-core 06/14] tests: TrafficResources class Noa Osherovich
2019-08-19  6:58 ` [PATCH rdma-core 07/14] tests: RCResources and UDResources classes Noa Osherovich
2019-08-19  6:58 ` [PATCH rdma-core 08/14] tests: ODP requires decorator Noa Osherovich
2019-08-19  6:58 ` [PATCH rdma-core 09/14] tests: Add traffic helper methods Noa Osherovich
2019-08-19  6:58 ` [PATCH rdma-core 10/14] tests: Add ODP RC test Noa Osherovich
2019-08-19  6:58 ` [PATCH rdma-core 11/14] tests: Add ODP UD test Noa Osherovich
2019-08-19  6:58 ` [PATCH rdma-core 12/14] tests: Fix test locating process Noa Osherovich
2019-08-19  6:58 ` [PATCH rdma-core 13/14] Documentation: Add background for rdma-core tests Noa Osherovich
2019-08-19  6:58 ` [PATCH rdma-core 14/14] tests: Unify API tests' output Noa Osherovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).