Handle duplicate SF in coverage.info to make sure coverage.xml gets correct statistics #3482
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What I did
use
--add-tracefile
option intests/conftest.py
to sanitizecoverage.info
generated bylcov
Why I did it
lcov
generates an initialcoverage.info
file based on collected.gcno
and.gcda
files, this.info
file contains coverage information for different source files (marked asSF
). Sometimes you would observe that the sameSF
appears multiple times, it meanslcov
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
generatescoverage.xml
based oncoverage.info
. However, it can't deal with duplicate SF incoverage.info
properly. 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-tracefile
option.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.