5import isystem.connect
as ic
6import isystem.itest
as it
12def verify_result(results):
13 while results.hasNextTestResult():
14 result = results.nextTestResult()
16 out = ic.CStringStream()
17 emitter = ic.EmitterFactory.createYamlEmitter(out)
19 emitter.startDocument(
False)
20 result.serializeErrorsOnly(emitter,
None)
21 emitter.endDocument(
False)
23 print(out.getString())
28def init_target() -> it.PTestCase:
29 cmgr = ic.ConnectionMgr()
30 cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
32 debug_ctrl = ic.CDebugFacade(cmgr)
36 debug_ctrl.runUntilFunction(
"main")
37 debug_ctrl.waitUntilStopped()
39 test_case = it.PTestCase(cmgr)
44def run_test_case(test_case: it.PTestCase):
49 test_case.itest(
"func: [get_random]",
None)
51 print(
"'get_random' finished!")
57 func: [sum, [3, 4, 5], retVal]
63 print(
'Test result:', end=
' ')
64 verify_result(test_case.getTestResultsContainer())
68def run_test_case_with_error(test_case: it.PTestCase):
72 func: [return_smaller, [3, 2], retVal]
78 print(
'return_smaller test result if error:', end=
' ')
79 verify_result(test_case.getTestResultsContainer())
83 test_case = init_target()
84 run_test_case(test_case)
85 run_test_case_with_error(test_case)
88if __name__ ==
'__main__':