]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Allow test selection with prefix wildcards
authorJouni Malinen <j@w1.fi>
Tue, 9 Jul 2019 13:09:04 +0000 (16:09 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 9 Jul 2019 13:10:44 +0000 (16:10 +0300)
Test names can now use wildcard in the end (e.g., ap_wpa2_psk*) to match
all test cases with the specified prefix.

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

index cb1496485fb1bbcd971d87b3a428bdb8592f531f..d291b9a1a1146ca4842c5b7d68cc82f33830d3c0 100755 (executable)
@@ -257,7 +257,17 @@ def main():
     if args.tests:
         fail = False
         for t in args.tests:
-            if t not in test_names:
+            if t.endswith('*'):
+                prefix = t.rstrip('*')
+                found = False
+                for tn in test_names:
+                    if tn.startswith(prefix):
+                        found = True
+                        break
+                if not found:
+                    print('Invalid arguments - test "%s" wildcard did not match' % t)
+                    fail = True
+            elif t not in test_names:
                 print('Invalid arguments - test "%s" not known' % t)
                 fail = True
         if fail:
@@ -292,7 +302,11 @@ def main():
         for selected in args.tests:
             for t in tests:
                 name = t.__name__.replace('test_', '', 1)
-                if name == selected:
+                if selected.endswith('*'):
+                    prefix = selected.rstrip('*')
+                    if name.startswith(prefix):
+                        tests_to_run.append(t)
+                elif name == selected:
                     tests_to_run.append(t)
     else:
         for t in tests: