Skip to content

Commit 481409e

Browse files
committed
panic: allow running specific test cases from command line
Small quality-of-life improvement, make it easier to run specific test cases, when debugging the tests locally. Take the optional list of test cases to run from the command line.
1 parent 7097303 commit 481409e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

tools/test_apps/system/panic/app_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
import sys
23
import panic_tests as test
34
from test_panic_util.test_panic_util import panic_test, run_all
45

@@ -247,4 +248,4 @@ def test_coredump_abort_flash_bin_crc(env, extra_data):
247248

248249

249250
if __name__ == '__main__':
250-
run_all(__file__)
251+
run_all(__file__, sys.argv[1:])

tools/test_apps/system/panic/test_panic_util/test_panic_util.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,19 @@ def get_dut(env, app_config_name, test_name, qemu_wdt_enable=False):
159159
return dut
160160

161161

162-
def run_all(filename):
163-
""" Helper function to run all test cases defined in a file; to be called from __main__. """
162+
def run_all(filename, case_filter=[]):
163+
""" Helper function to run test cases defined in a file; to be called from __main__.
164+
case_filter is an optional list of case names to run.
165+
If not specified, all test cases are run.
166+
"""
164167
TinyFW.set_default_config(env_config_file=None, test_suite_name=TEST_SUITE)
165168
test_methods = SearchCases.Search.search_test_cases(filename)
166169
test_methods = filter(lambda m: not m.case_info["ignore"], test_methods)
167170
test_cases = CaseConfig.Parser.apply_config(test_methods, None)
168171
tests_failed = []
169172
for case in test_cases:
173+
if case_filter and case.test_method.__name__ not in case_filter:
174+
continue
170175
result = case.run()
171176
if not result:
172177
tests_failed.append(case)

0 commit comments

Comments
 (0)