-
Notifications
You must be signed in to change notification settings - Fork 9
contest: vm: capture code coverage #40
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
Conversation
Code coverage is a valuable info to get to know how much we can trust a test suite, and easily find out what needs to be improved. It is quite easy to get such info with the kernel: - The kernel needs to be compiled with GCOV_KERNEL=y, and have either GCOV_PROFILE_ALL=y, or GCOV_PROFILE := y set in the Makefiles. The recommended way is to add 'GCOV_PROFILE' in net/Makefile and drivers/net/Makefile. - Before stopping the VM, the LCOV file can be captured using the 'lcov' tool, version >= 2.0 is recommended. - 'genhtml' from the LCOV project can be used later to generate an HTML version using all the .lcov files. It could be done per LCOV file, but that will then only show the coverage per VM, not the global one. This GCOV support is disabled by default. It can be enabled via 'vm.gcov=on'. I suggest to keep it off by default, and switch it to on later when everything is in place. Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
Hi! Very sorry for the delay, the GitHub PRs were last on my catch up list after PTO :) |
There was no hurry at all, especially because I cannot provide a full implementation :)
Thanks! Yes, I think it can be merged as is. The feature is disabled by default anyway. There are not a lot of modifications, hopefully I didn't break anything :)
Generating the
Then it's less clear how the rest would be done, but the idea is to run
Good point: I think a good starting point is to do it either per batch of tests: once every 3 hours, or once a day. I don't have a clear view on how to collect of the different generated |
Does the GCOV generation slow things down significantly? Is there a way to generate deltas between two reports? I think it may be more interesting to see than raw results? We use multiple VMs per TARGET and reuse VM for multiple tests. Do you generate the coverage for all tests together or for each one individually? |
On MPTCP side, I didn't notice any big impact, but we only enable GCOV for code from
I found It looks like it will show the diff between two lcov files. On MPTCP side, the generated files are not used on a daily basis, but more to see where we are missing some code coverage. Implementing the diff is a bit harder just to retrieve files generated from a previous build, maybe not an issue for NIPA. We can compare the general coverage, e.g. each build on MPTCP side prints this on the summary page (the last 4 lines produced by
If the HTML files generated by
I think what is more interesting is to get the global coverage: after having executed all tests. So I would say: one file per VM (what's currently done in this PR), then we combine everything by using |
Thanks for all the info! I added the coverage support to the TODO list: https://docs.google.com/spreadsheets/d/1mFnt91SKtA9ENIUfY0v2UmZSXJzmvsa4oqha4t6JVBs/edit?pli=1&gid=1985743919#gid=1985743919 |
Code coverage is a valuable info to get to know how much we can trust a test suite, and easily find out what needs to be improved.
Here is what it looks like for MPTCP: https://ci-results.mptcp.dev/lcov/export/index.html
(This is also visible on Coveralls.)
It is quite easy to get such info with the kernel, but it needs extra steps on the host (maybe we can switch this PR to a Draft):
The kernel needs to be compiled with
GCOV_KERNEL=y
: this is handled by the modification suggested here, usingvng -b --configitem
. It requires virtme-ng >=1.26.GCOV profile also needs to be enabled, either with
GCOV_PROFILE_ALL=y
kconfig, but it is not recommended, orGCOV_PROFILE := y
set in theMakefile
's. I recommend adding a new commit to the branches that are created by NIPA, with a content that is similar to this (GCOV_PROFILE
added in the header section to avoid future conflicts):Before stopping the VM, the LCOV file is now captured using the
lcov
tool, version >= 2.0 is recommended. This tool needs to be added on the machines running the tests, the scripts are now going to use them from the VM.The last step is to use
genhtml
from the LCOV project to generate an HTML version using all the.lcov
files. (It could be done per LCOV file, but that will then only show the coverage per VM, not the global one.). I guess this needs to be done in a separated script, after the end of all tests, using all the collected.lcov
file, but it is not clear to me how to do that. Here is the command that needs to be executed:This GCOV support is disabled by default. It can be enabled via
vm.gcov=on
. I suggest keeping it off by default, and switch it to on later when everything is in place.Note: on MPTCP side, I use a simple Docker image. If it is difficult to use LCOV >=2.0 on your side, a workaround is to add a file called
lcov
somewhere in your$PATH
with this content (+ a symlink forgenhtml
):One last thing: it might be good to also add this support when running the KUnit tests, but it is not clear to me how to integrate with
tools/testing/kunit/kunit.py
.