import isystem.connect as ic
import time
winidea_id = ''
def test_resetAndRun():
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
execCtrl = ic.CExecutionController(connMgr)
sessionCtrl = ic.CSessionCtrl(connMgr)
addCtrl = ic.CAddressController(connMgr)
bpCtrl = ic.CBreakpointController(connMgr)
sessionCtrl.begin_prepare()
execCtrl.runUntilFunction('main')
print("`resetAndRun` the CPU without timeout (not expecting `STOP` state)...")
execCtrl.resetAndRun()
address = addCtrl.getFunctionAddress("main").getAddress()
print(f"Setting BP at function 'main': {hex(address)}")
bpCtrl.setBP(0, address)
sessionCtrl.begin_reset()
print("`resetAndRun` the CPU with 1 sec timeout (expecting stop at function 'main')...")
if execCtrl.resetAndRun(ic.CExecutionController.TOUT_1s) == 0:
print("\tSuccess.")
else:
print("\tTIMEOUT!")
bpCtrl.deleteAll()
if __name__ == "__main__":
test_resetAndRun()