winIDEA SDK
Loading...
Searching...
No Matches
test_get_statistic.py
# This script is licensed under BSD License, see file LICENSE.txt, or search for `License` in the SDK online help.
#
# (c) TASKING Germany GmbH, 2023
import os
import isystem.connect as ic
from coverage_data import test_get_coverage_meta_info as cvrg
winidea_id = ''
def test_getStatistic():
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
ideCtrl = ic.CIDEController(connMgr)
xmlFilePath = os.path.join(ideCtrl.getPath(ic.CIDEController.WORKSPACE_DIR), "cvrgExport.xml")
cvrg._exportCoverageToXML(connMgr, 'sdk_example.trd', "cvrgExport.xml")
covData = ic.CCoverageData2.createInstance(xmlFilePath, True)
print(f"Get execution statistics for module 'main' (by name):")
stat = covData.getStatistic(ic.CCoverageStatistic2.EModule, "main.cpp")
print("\tNumber of called functions:", stat.getExecutionCount(), "(function 'main')")
print("\tExecuted lines:", stat.getLinesExecuted(), "out of:", stat.getLinesAll())
print(f"Get statistics explicitly defined by symbol data:")
stat = covData.getStatistic("sdk_example_stm32.elf", 'build/debug', "utils.cpp", "fibonacci")
print("\tFunction calls count:", stat.getCallCount())
print("\tExecuted code (in bytes):", stat.getBytesExecuted(), "out of:", stat.getBytesAll())
covData.closeParser()
if __name__ == "__main__":
test_getStatistic()