5import isystem.connect
as ic
6import isystem.itest
as it
13def init_target() -> ic.ConnectionMgr:
14 connection_mgr = ic.ConnectionMgr()
15 connection_mgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
17 debug_ctrl = ic.CDebugFacade(connection_mgr)
19 debug_ctrl.runUntilFunction(
'main')
20 debug_ctrl.waitUntilStopped()
25def run_tests_recursive(test_case: it.PTestCase, test_spec: ic.CTestSpecification,
26 filter_tag: str, results: List[ic.CTestResult]):
28 This method runs derived tests recursively. Some basic filtering
32 if test_spec.getRunFlag():
34 merged_test_spec = test_spec.merge()
37 merged_test_spec.getTags(tags)
39 if filter_tag
in tags:
42 print(
'executing:', merged_test_spec.getTestId())
43 test_case.itest(merged_test_spec,
None)
44 results.append(test_case.getTestResultsContainer().nextTestResult())
46 num_derived_test_specs = test_spec.getNoOfDerivedSpecs()
47 for idx
in range(0, num_derived_test_specs):
48 run_tests_recursive(test_case, test_spec.getDerivedTestSpec(idx), filter_tag, results)
51def run_tests(connection_mgr: ic.ConnectionMgr) -> List[ic.CTestResult]:
52 print(
"Should run only tests with IDs 'test-2' and 'test-2-1'")
54 test_case = it.PTestCase(connection_mgr)
59 test_bench = ic.CTestBench.load(
'test_min_int.iyaml', 0)
60 root_test_spec = test_bench.getTestSpecification(
True)
62 root_test_spec.setRunFlag(
False)
66 tag_used_for_test_filtering =
'extended'
67 run_tests_recursive(test_case, root_test_spec, tag_used_for_test_filtering, test_results)
72def print_test_results(test_results: List[ic.CTestResult]):
73 for test_result
in test_results:
74 if test_result.isError():
75 print(
"Error: ", test_result.getTestId())
77 print(
"OK: ", test_result.getTestId())
82 test_results = run_tests(cmgr)
83 print_test_results(test_results)
86if __name__ ==
'__main__':