5import isystem.connect
as ic
6import isystem.itest
as it
12def verifyResult(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() -> ic.ConnectionMgr:
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()
41def run_tests(cmgr: ic.ConnectionMgr):
42 test_case = it.PTestCase(cmgr)
44 itest_ctrl = ic.CSystemTestController(cmgr)
46 itest_ctrl.createPersistentVariable(
'myvar1',
'int')
47 itest_ctrl.createPersistentVariable(
'myvar2',
'int')
48 itest_ctrl.createPersistentVariable(
'myvar3',
'int')
49 itest_ctrl.initPersistentVars()
51 itest_ctrl.modify(
'myvar1',
'123')
52 itest_ctrl.modify(
'myvar2',
'456')
53 itest_ctrl.modify(
'myvar3',
'789')
55 print(
'Variable exists before the test: ', itest_ctrl.evaluate(
'myvar1,d'))
56 print(
'Variable exists before the test: ', itest_ctrl.evaluate(
'myvar2,d'))
57 print(
'Variable exists before the test: ', itest_ctrl.evaluate(
'myvar3,d'))
61 func: [sum, [myvar1, myvar2, myvar3], retVal]
70 verifyResult(test_case.getTestResultsContainer())
72 print(
'Variable exists between tests: ', itest_ctrl.evaluate(
'myvar1,d'))
73 print(
'Variable exists between tests: ', itest_ctrl.evaluate(
'myvar2,d'))
74 print(
'Variable exists between tests: ', itest_ctrl.evaluate(
'myvar3,d'))
78 func: [sum, [123, 456, 789], retVal]
83 - retVal == (myvar1 + myvar2 + myvar3)
87 verifyResult(test_case.getTestResultsContainer())
89 print(
'Variable exists after tests: ', itest_ctrl.evaluate(
'myvar1,d'))
90 print(
'Variable exists after tests: ', itest_ctrl.evaluate(
'myvar2,d'))
91 print(
'Variable exists after tests: ', itest_ctrl.evaluate(
'myvar3,d'))
93 itest_ctrl.cleanPersistentVars()
96 print(
'Variable should no longer exist after cleanup: ', itest_ctrl.evaluate(
'myvar1,d'))
97 print(
'Variable should no longer exist after cleanup: ', itest_ctrl.evaluate(
'myvar2,d'))
98 print(
'Variable should no longer exist after cleanup: ', itest_ctrl.evaluate(
'myvar3,d'))
100 print(
'\nPersistent variables no longer exist.')
102 raise Exception(
'Variable should no longer exist after cleanup!')
110if __name__ ==
'__main__':