5import isystem.itest
as it
6import isystem.connect
as ic
12class TestCustomMethods:
14 This class contains methods to be called during test execution.
15 The names of the methods must match those
in test specification
16 tags
'endFunc' and 'initFunc'.
19 def __init__(self, connection_mgr: ic.ConnectionMgr, debug_ctrl: ic.CDebugFacade):
21 We can use constructor to store references to other objects
22 used by methods of this class.
24 self.connectionMgr = connection_mgr
25 self.__dbg = debug_ctrl
27 def my_init_test_func(self, a, b):
28 print(
'my_init_test_func:')
29 print(
' Is target stopped:', self.__dbg.getCPUStatus().isStopped())
31 print(
' a = ' + str(a))
32 print(
' b = ' + str(b))
34 def my_end_test_func(self, a, b, c):
35 print(
'my_end_test_func:')
36 print(
' a = ' + str(a))
37 print(
' b = ' + str(b))
38 print(
' c = ' + str(c))
40 def my_init_target_func(self, a, b):
41 print(
'my_init_target_func:')
42 print(
' target status:' + self.__dbg.getCPUStatus().toString())
43 print(
' a = ' + str(a))
44 print(
' b = ' + str(b))
46 def my_restore_target_func(self, param):
47 print(
'my_restore_target_func:')
50 def my_stub_hit_func(self, param):
51 print(
'my_stub_hit_func:')
52 print(
' ' + str(param))
54 testCtrl = ic.CTestCaseController(self.connectionMgr, self._isys_testCaseHandle)
55 testCtrl.modify(
'srv',
'144')
58def init_target() -> [ic.ConnectionMgr, ic.CDebugFacade]:
59 cmgr = ic.ConnectionMgr()
60 cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
62 debug_ctrl = ic.CDebugFacade(cmgr)
64 debug_ctrl.runUntilFunction(
'main')
65 debug_ctrl.waitUntilStopped()
66 return cmgr, debug_ctrl
69def run_test(cmgr: ic.ConnectionMgr, debug_ctrl: ic.CDebugFacade):
71 test_case = it.PTestCase(cmgr)
76 custom_methods = TestCustomMethods(cmgr, debug_ctrl)
81 - func: [fibonacci, srv]
82 script: [my_stub_hit_func, ["['param1', 'param2']"]]
84 initFunc: [my_init_test_func, [1, 2]]
85 endFunc: [my_end_test_func, [3, 4,
'''a''']]
86 initTargetFunc: [my_init_target_func, [123, 987]]
87 restoreTargetFunc: [my_restore_target_func, [
'"paramX"']]
90 results = test_case.getTestResultsContainer()
95 print(
'\n--------------------------------\n')
97 if not result.isError():
101 if result.isException():
102 print(
'Exception: ', result.getExceptionString())
104 if result.isExpressionError():
105 data_results = ic.StrVector()
106 result.getExpressionResults(data_results)
107 for expr_result
in data_results:
108 if len(expr_result) > 0:
111 if result.isCodeCoverageError():
112 print(
'Code Coverage Error')
114 if result.isProfilerCodeError():
115 print(
'Profiler Code Error')
117 if result.isProfilerDataError():
118 print(
'Profiler Data Error')
122 cmgr, debug_ctrl = init_target()
124 run_test(cmgr, debug_ctrl)
127if __name__ ==
'__main__':