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.
This commit is contained in:
Ivan Grokhotkov 2020-07-29 12:24:39 +02:00
parent 709730317b
commit 481409ec05
2 changed files with 9 additions and 3 deletions

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python
import sys
import panic_tests as test
from test_panic_util.test_panic_util import panic_test, run_all
@ -247,4 +248,4 @@ def test_coredump_abort_flash_bin_crc(env, extra_data):
if __name__ == '__main__':
run_all(__file__)
run_all(__file__, sys.argv[1:])

View File

@ -159,14 +159,19 @@ def get_dut(env, app_config_name, test_name, qemu_wdt_enable=False):
return dut
def run_all(filename):
""" Helper function to run all test cases defined in a file; to be called from __main__. """
def run_all(filename, case_filter=[]):
""" Helper function to run test cases defined in a file; to be called from __main__.
case_filter is an optional list of case names to run.
If not specified, all test cases are run.
"""
TinyFW.set_default_config(env_config_file=None, test_suite_name=TEST_SUITE)
test_methods = SearchCases.Search.search_test_cases(filename)
test_methods = filter(lambda m: not m.case_info["ignore"], test_methods)
test_cases = CaseConfig.Parser.apply_config(test_methods, None)
tests_failed = []
for case in test_cases:
if case_filter and case.test_method.__name__ not in case_filter:
continue
result = case.run()
if not result:
tests_failed.append(case)