@@ -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")
-
-
@@ -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', ...))
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(-)