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

Is using "function coverage" metric instead of "line coverage" intended? #170

Closed
mtjhrc opened this issue Oct 22, 2024 · 1 comment · Fixed by #171
Closed

Is using "function coverage" metric instead of "line coverage" intended? #170

mtjhrc opened this issue Oct 22, 2024 · 1 comment · Fixed by #171
Labels
bug Something isn't working

Comments

@mtjhrc
Copy link

mtjhrc commented Oct 22, 2024

While working with @dorindabassey on a gpu in vhost-device, she has noticed the CI seem to be using the "function coverage" metric of llvm-cov. Then I also noticed the comment in the python code of the CI, that seems to suggest "line coverage" is intended to be used.

# Output of llvm-cov is like
# TOTAL 743 153 79.41% 185 50 72.97% 1531 125 91.84% 0 0 -
# where the first three numbers are related to region coverage, and next three to line coverage (what we want)
# and the last three to branch coverage (which is not yet supported). Below grabs the line coverage, and strips
# off the '%'.
coverage = float(summary.split()[6][:-1])

The comment here doesn't seem to be correct - at least on my machine the order of the columns in the CLI output of cargo llvm-cov test --summary-only is: Region coverage, Function coverage, Line coverage.

Confusingly the order of the columns is different when using the html output (cargo llvm-cov test --open): Function coverage, Line coverage, Region coverage.

Btw there is also cargo llvm-cov test --json --summary-only which could prevent such confusion.

This means that it seems like the projects using this CI, use the function coverage metric instead of line coverage.
Is this intended or it is it a bug in the parsing of the output? I would think the original intention was to use line coverage.

@roypat roypat added the bug Something isn't working label Oct 22, 2024
@roypat
Copy link
Collaborator

roypat commented Oct 22, 2024

Hey, thanks for reporting this! Yes, that is indeed supposed to be line coverage! I wonder something changed on llvm-cov's side recently (there was a rust toolchain update that caused weird changes of the coverage numbers all over the place). The json option does indeed sound more robust. I'll have a look into fixing this tomorrow morning (although if you already have a fix, please feel free to open a PR and I'll have a look at that instead :)

roypat added a commit to roypat/rust-vmm-ci that referenced this issue Oct 23, 2024
It seems that the raw output of llvm-cov changed at some point, and we
ended upcomparing functoin coverage instead of line coverage. Fix this
by instead using the new json output, which will hopefully prevent such
goofs in the future.

Fixes rust-vmm#170
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
roypat added a commit to roypat/rust-vmm-ci that referenced this issue Oct 23, 2024
It seems that the raw output of llvm-cov changed at some point, and we
ended upcomparing functoin coverage instead of line coverage. Fix this
by instead using the new json output, which will hopefully prevent such
goofs in the future.

Fixes rust-vmm#170
Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
@roypat roypat closed this as completed in 1150c47 Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants