From 88b6c6e244341f9874eceb5a50767e65d2113936 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 9 Jul 2019 16:09:04 +0300 Subject: [PATCH] tests: Allow test selection with prefix wildcards 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 --- tests/hwsim/run-tests.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/hwsim/run-tests.py b/tests/hwsim/run-tests.py index cb1496485..d291b9a1a 100755 --- a/tests/hwsim/run-tests.py +++ b/tests/hwsim/run-tests.py @@ -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: