winIDEA SDK
test_get_active_stub.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import isystem.connect as ic
6
7
8# This is an example how to crash winIDEA. Sample might be wrong, as it
9# was a work in progress, but winIDEA shouldn't crash anyway.
10
11winidea_id = ''
12
13
14def test_getActiveStub():
15 connMgr = ic.ConnectionMgr()
16 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
17
18 execCtrl = ic.CExecutionController(connMgr)
19 session = ic.CSessionCtrl(connMgr)
20 session.begin_program()
21 execCtrl.runUntilFunction('main') # make sure stack is initialized
22 execCtrl.waitUntilStopped()
23
24 tcCtrl = ic.CTestCaseController(connMgr, "getNumber", "")
25 tcCtrl.createParameter(0, "x")
26 print("Creating stub ...")
27 tcCtrl.createStub('timesTwo')
28 tcCtrl.init()
29
30 tcCtrl.run()
31 tcCtrl.waitUntilStopped()
32
33 tcStatus = tcCtrl.getStatus()
34 print(f"Current test case state: {ic.CTestCaseController.testState2str(tcStatus)}")
35 if tcStatus == ic.IConnectTest.stateStub:
36 print(f"Active stub name: {tcCtrl.getActiveStub().getStubName()}")
37 else:
38 print("No active stub...")
39
40 tcCtrl.run()
41 tcCtrl.waitUntilStopped()
42
43 tcCtrl.destroy()
44
45
46if __name__ == "__main__":
47 test_getActiveStub()