tests: Make run-tests.py process test case selection arguments
authorJouni Malinen <j@w1.fi>
Tue, 18 Nov 2014 22:34:36 +0000 (00:34 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 19 Nov 2014 13:20:52 +0000 (15:20 +0200)
This allows a list of matching test cases to be produced without having
to run the test cases. Previously, -L output included all defined test
cases regardless of what else was included on the command line.

Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/run-tests.py

index 7352a1c..be9b77f 100755 (executable)
@@ -240,8 +240,29 @@ def main():
     if conn:
         run = int(time.time())
 
+    # read the modules from the modules file
+    if args.mfile:
+       args.testmodules = []
+       with open(args.mfile) as f:
+           for line in f.readlines():
+               line = line.strip()
+               if not line or line.startswith('#'):
+                   continue
+               args.testmodules.append(line)
+
+    tests_to_run = []
+    for t in tests:
+        name = t.__name__.replace('test_', '', 1)
+        if args.tests:
+            if not name in args.tests:
+                continue
+        if args.testmodules:
+            if not t.__module__.replace('test_', '', 1) in args.testmodules:
+                continue
+        tests_to_run.append(t)
+
     if args.update_tests_db:
-        for t in tests:
+        for t in tests_to_run:
             name = t.__name__.replace('test_', '', 1)
             if t.__doc__ is None:
                 print name + " - MISSING DESCRIPTION"
@@ -292,27 +313,6 @@ def main():
     if args.dmesg:
         subprocess.call(['sudo', 'dmesg', '-c'], stdout=open('/dev/null', 'w'))
 
-    # read the modules from the modules file
-    if args.mfile:
-       args.testmodules = []
-       with open(args.mfile) as f:
-           for line in f.readlines():
-               line = line.strip()
-               if not line or line.startswith('#'):
-                   continue
-               args.testmodules.append(line)
-
-    tests_to_run = []
-    for t in tests:
-        name = t.__name__.replace('test_', '', 1)
-        if args.tests:
-            if not name in args.tests:
-                continue
-        if args.testmodules:
-            if not t.__module__.replace('test_', '', 1) in args.testmodules:
-                continue
-        tests_to_run.append(t)
-
     if conn and args.prefill:
         for t in tests_to_run:
             name = t.__name__.replace('test_', '', 1)