winIDEA SDK
test_get_statistic.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import os
6import isystem.connect as ic
7import test_getCoverageMetaInfo as cvrg
8
9
10winidea_id = ''
11
12
13def test_getStatistic():
14 connMgr = ic.ConnectionMgr()
15 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
16
17 ideCtrl = ic.CIDEController(connMgr)
18 xmlFilePath = os.path.join(ideCtrl.getPath(ic.CIDEController.WORKSPACE_DIR), "cvrgExport.xml")
19 cvrg._exportCoverageToXML(connMgr, 'example.trd', "cvrgExport.xml")
20 covData = ic.CCoverageData2.createInstance(xmlFilePath, True)
21
22 print(f"Get execution statistics for module 'main' (by name):")
23 stat = covData.getStatistic(ic.CCoverageStatistic2.EModule, "main.cpp")
24 print("\tNumber of called functions:", stat.getExecutionCount(), "(function 'main')")
25 print("\tExecuted lines:", stat.getLinesExecuted(), "out of:", stat.getLinesAll())
26
27 print(f"Get statistics explicitly defined by symbol data:")
28 stat = covData.getStatistic("sdk_example_stm32.elf", 'build/debug', "utils.cpp", "fibonacci")
29 print("\tFunction calls count:", stat.getCallCount())
30 print("\tExecuted code (in bytes):", stat.getBytesExecuted(), "out of:", stat.getBytesAll())
31
32 covData.closeParser()
33
34
35if __name__ == "__main__":
36 test_getStatistic()