Handle duplicate SF in coverage.info to make sure coverage.xml gets correct statistics#3482
Handle duplicate SF in coverage.info to make sure coverage.xml gets correct statistics#3482prsunny merged 1 commit intosonic-net:masterfrom
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run Azure.sonic-swss |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
This coverage.zip contains the coverage.info and buggy coverage.xml obtained from artifacts of PR#3242, without the change of this PR#3482. you can check by searching But in What this #PR3482 wants to fix is that, use --add-trace-file option for lcov, so that it could sum up all |
|
The best fix for this is to rework the automake build files to not need to compile the same files repeatedly. This probably involves switching to non-recursive automake, and takes a bit of time to do so without breaking anything. This is a good enough short-term fix, at least. |
….info (sonic-net#3482)" This reverts commit 455027e.
…coverage.info (sonic-net#3482)"" This reverts commit 47ce8e0.
…e SF in coverage.info (sonic-net#3482)""" This reverts commit 07075f8.
…onic-net#3482) What I did use --add-tracefile option in debian/rules and tests/conftest.py to sanitize coverage.info generated by lcov Why I did it lcov generates an initial coverage.info file based on collected .gcno and .gcda files, this .info file contains coverage information for different source files (marked as SF). Sometimes you would observe that the same SF appears multiple times, it means lcov gets multiple copies of coverage information for this file, since this file may have appeared in multiple compilation units, and for each copy, the hit times of its lines are different. Then lcov_cobertura generates coverage.xml based on coverage.info. However, it can't deal with duplicate SF in coverage.info properly. If it sees duplicate coverage information for a source file from coverage.info, it always overwrites the old copy with the new copy, hence only the last copy would be counted. However, if the last copy considers the functions as missing, the function is considered as missing in coverage.xml, which is used to determine whether the new PR passes the coverage threshold. The proper way is to add the hit times of all the copies, which could be achieved by lcov add-tracefile option.
…onic-net#3482) What I did use --add-tracefile option in debian/rules and tests/conftest.py to sanitize coverage.info generated by lcov Why I did it lcov generates an initial coverage.info file based on collected .gcno and .gcda files, this .info file contains coverage information for different source files (marked as SF). Sometimes you would observe that the same SF appears multiple times, it means lcov gets multiple copies of coverage information for this file, since this file may have appeared in multiple compilation units, and for each copy, the hit times of its lines are different. Then lcov_cobertura generates coverage.xml based on coverage.info. However, it can't deal with duplicate SF in coverage.info properly. If it sees duplicate coverage information for a source file from coverage.info, it always overwrites the old copy with the new copy, hence only the last copy would be counted. However, if the last copy considers the functions as missing, the function is considered as missing in coverage.xml, which is used to determine whether the new PR passes the coverage threshold. The proper way is to add the hit times of all the copies, which could be achieved by lcov add-tracefile option. Signed-off-by: Baorong Liu <96146196+baorliu@users.noreply.github.com>
What I did
use
--add-tracefileoption indebian/rulesandtests/conftest.pyto sanitizecoverage.infogenerated bylcovWhy I did it
lcovgenerates an initialcoverage.infofile based on collected.gcnoand.gcdafiles, this.infofile contains coverage information for different source files (marked asSF). Sometimes you would observe that the sameSFappears multiple times, it meanslcovgets multiple copies of coverage information for this file, since this file may have appeared in multiple compilation units, and for each copy, the hit times of its lines are different.Then
lcov_coberturageneratescoverage.xmlbased oncoverage.info. However, it can't deal with duplicate SF incoverage.infoproperly. If it sees duplicate coverage information for a source file fromcoverage.info, it always overwrites the old copy with the new copy, hence only the last copy would be counted. However, if the last copy considers the functions as missing, the function is considered as missing incoverage.xml, which is used to determine whether the new PR passes the coverage threshold.The proper way is to add the hit times of all the copies, which could be achieved by lcov
add-tracefileoption.How I verified it
Before using
--add-tracefile, RingBuffer related functions in this PR are considered missing, though they are covered in testcases. After adding--add-tracefile, it passes the coverage check.[orchagent] implement ring buffer feature with a flag #3242
Details if related
By downloading the artifact of PR#3242, we could check coverage.xml, which has already had the correct statistics.