diff mbox series

[1/3] tests: remote: allow to run module tests

Message ID 20200308132704.22068-1-janusz.dziedzic@gmail.com
State Accepted
Headers show
Series [1/3] tests: remote: allow to run module tests | expand

Commit Message

Janusz Dziedzic March 8, 2020, 1:27 p.m. UTC
Add switch: -f
that will run all test from specyfic module(s).

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@gmail.com>
---
 tests/remote/run-tests.py | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

Comments

Jouni Malinen March 8, 2020, 3:36 p.m. UTC | #1
Thanks, all three patches applied.

> +        opts, args = getopt.getopt(sys.argv[1:], "d:f:r:t:l:k:c:m:h:vRPT",
> +                                   ["dut=", "mod=", "ref=", "tests=", "log-dir=",

> +        elif option in ("-f", "--modules"):
> +            requested_modules = re.split('; | |, ', argument)

With that mismatch between "mod" and "modules" fixed.
diff mbox series

Patch

diff --git a/tests/remote/run-tests.py b/tests/remote/run-tests.py
index e1ff98977..d82d0d9f0 100755
--- a/tests/remote/run-tests.py
+++ b/tests/remote/run-tests.py
@@ -32,7 +32,7 @@  from hwsim_wrapper import run_hwsim_test
 def usage():
     print("USAGE: " + sys.argv[0] + " -t devices")
     print("USAGE: " + sys.argv[0] + " -t check_devices")
-    print("USAGE: " + sys.argv[0] + " -d <dut_name> -t <all|sanity|tests_to_run> [-r <ref_name>] [-c <cfg_file.py>] [-m <all|monitor_name>] [-h hwsim_tests][-R][-T][-P][-v]")
+    print("USAGE: " + sys.argv[0] + " -d <dut_name> -t <all|sanity|tests_to_run> [-r <ref_name>] [-c <cfg_file.py>] [-m <all|monitor_name>] [-h hwsim_tests] [-f hwsim_modules][-R][-T][-P][-v]")
     print("USAGE: " + sys.argv[0])
 
 def get_devices(devices, duts, refs, monitors):
@@ -71,6 +71,8 @@  def main():
     requested_tests = ["help"]
     requested_hwsim_tests = []
     hwsim_tests = []
+    requested_modules = []
+    modules_tests = []
     cfg_file = "cfg.py"
     log_dir = "./logs/"
     verbose = False
@@ -80,8 +82,8 @@  def main():
 
     # parse input parameters
     try:
-        opts, args = getopt.getopt(sys.argv[1:], "d:r:t:l:k:c:m:h:vRPT",
-                                   ["dut=", "ref=", "tests=", "log-dir=",
+        opts, args = getopt.getopt(sys.argv[1:], "d:f:r:t:l:k:c:m:h:vRPT",
+                                   ["dut=", "mod=", "ref=", "tests=", "log-dir=",
                                     "cfg=", "key=", "monitor=", "hwsim="])
     except getopt.GetoptError as err:
         print(err)
@@ -113,6 +115,8 @@  def main():
             cfg_file = argument
         elif option in ("-h", "--hwsim"):
             requested_hwsim_tests = re.split('; | |, ', argument)
+        elif option in ("-f", "--modules"):
+            requested_modules = re.split('; | |, ', argument)
         else:
             assert False, "unhandled option"
 
@@ -208,6 +212,22 @@  def main():
                     continue
                 hwsim_tests_to_run.append(t)
 
+    # import test_* from modules
+    files = os.listdir("../hwsim/")
+    for t in files:
+        m = re.match(r'(test_.*)\.py$', t)
+        if m:
+            mod = __import__(m.group(1))
+            if mod.__name__.replace('test_', '', 1) not in requested_modules:
+                continue
+            for key, val in mod.__dict__.items():
+                if key.startswith("test_"):
+                    modules_tests.append(val)
+
+    if len(requested_modules) > 0:
+        requested_hwsim_tests = modules_tests
+        hwsim_tests_to_run = modules_tests
+
     # sort the list
     test_names.sort()
     tests.sort()