From 481409ec0540182c703e93b983d354c8e15f42f6 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Wed, 29 Jul 2020 12:24:39 +0200 Subject: [PATCH] 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. --- tools/test_apps/system/panic/app_test.py | 3 ++- .../system/panic/test_panic_util/test_panic_util.py | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/test_apps/system/panic/app_test.py b/tools/test_apps/system/panic/app_test.py index 8dc316d60f..231f42daf8 100644 --- a/tools/test_apps/system/panic/app_test.py +++ b/tools/test_apps/system/panic/app_test.py @@ -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:]) diff --git a/tools/test_apps/system/panic/test_panic_util/test_panic_util.py b/tools/test_apps/system/panic/test_panic_util/test_panic_util.py index d50c100861..6229f6c402 100644 --- a/tools/test_apps/system/panic/test_panic_util/test_panic_util.py +++ b/tools/test_apps/system/panic/test_panic_util/test_panic_util.py @@ -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)