Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle duplicate SF in coverage.info to make sure coverage.xml gets correct statistics #3482

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

a114j0y
Copy link
Contributor

@a114j0y a114j0y commented Jan 24, 2025

What I did
use --add-tracefile option in 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.

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.

@a114j0y a114j0y requested a review from prsunny as a code owner January 24, 2025 19:24
@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@yuezhoujk
Copy link

/azp run Azure.sonic-swss

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants