import time
import isystem.connect as ic
winidea_id = ''
def init_target() -> ic.ConnectionMgr:
cmgr = ic.ConnectionMgr()
cmgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
debug_ctrl = ic.CDebugFacade(cmgr)
session_ctrl = ic.CSessionCtrl(cmgr)
session_ctrl.begin_reset()
debug_ctrl.runUntilFunction("main")
debug_ctrl.waitUntilStopped()
return cmgr
def run_test(cmgr: ic.ConnectionMgr):
test_controller = ic.CSystemTestController(cmgr)
stub_controller = test_controller.createStub('process_strings')
test_controller.createUserStub('get_random', 'stub_demo')
test_controller.init()
test_controller.run()
test_controller.waitUntilStopped()
testStatus = test_controller.getStatus()
if testStatus == ic.IConnectTest.stateStub:
print(f"Stub '{stub_controller.getStubName()}' hit.")
else:
raise Exception(f"Execution did not stop on stub. Status = {testStatus}")
test_controller.run()
time.sleep(2)
test_controller.stop()
g_process_counter = int(test_controller.evaluate('g_process_counter,d'), 0)
if g_process_counter == 0:
print('OK, function was stubbed!')
else:
print(f'ERROR: function was NOT stubbed! g_process_counter = {g_process_counter}')
test_controller.destroy()
print('OK')
def main():
cmgr = init_target()
print('initialized')
run_test(cmgr)
if __name__ == '__main__':
main()