I am using Waf to build a C project and gcov
to have some test code coverage. However, Waf calls gcc
in a way that produces foo.c.1.o
from source file foo.c
that confuses gcov
when searching for the generated files:
$ gcov foo.c
$ foo.gcno:cannot open graph file
Fortunately, gcov
has the -o
option with which it is possible to specify the corresponding object file. Nevertheless, this is not convenient and executing lcov
still fails. Therefore, my questions are:
gcov
/lcov
work around this issue?You can use gcovr
instead of directly running gcov
.
gcovr
does not rely on file name magic, but parses gcov
's coverage files.
It then calls gcov
with the appropriate parameters.
This works great with Waf's object file renaming.
You can run gcovr
from Waf's build
subdirectory:
cd build
gcovr --root=$(pwd) --keep
lcov --capture --directory $(pwd) --base-directory $(pwd) --output-file coverage.info
genhtml coverage.info --output-directory out
The --root
option removes the current directory prefix
The --keep
option keeps gcov
's temporary files, used by lcov
/genhtml
.
You can also use gcovr
's --xml
option to produce Cobertura-compatible xml output.
It can then be used by various formatters (I use it with Jenkins' Cobertura Plugin)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With