My source and build tree looks like this (see Makefile to put object files from source files different directories into a single, separate directory?) after a make (which builds and runs FooAndBarTests):
src
- Foo.cpp
- Bar.cpp
inc
- Foo.h
- Bar.h
test
- FooTest.cpp
- BarTest.cpp
- Main.cpp
- Makefile
- obj
- Foo.gcda
- Foo.gcno
- Bar.gcda
- Bar.gcno
- FooAndBarTests
UnitTest++
- libUnitTest++.a
- src
- ...
I can then produce .gcov files in the test directory by running gcov -o obj/ ../src/Foo.cpp
and gcov -o obj/ ../src/Bar.cpp
.
But if I run lcov -d obj/ -c -o FooAndBarTests.lcov
I get:
Capturing coverage data from obj/
Found gcov version: 4.2.1
Scanning obj/ for .gcda files ...
Found 4 data files in obj/
Processing Foo.gcda
../src/Foo.cpp:cannot open source file
Processing FooTest.gcda
FooTest.cpp:cannot open source file
../inc/Foo.h:cannot open source file
../UnitTest++/src/Checks.h:cannot open source file
...
And then when I run genhtml FooAndBarTests.lcov
I get:
Reading data file FooAndBarTests.lcov
Found 45 entries.
Found common filename prefix "/Users/dspitzer/FooAndBar/test"
Writing .css and .png files.
Generating output.
Processing file UnitTest++/src/Checks.h
genhtml: ERROR: cannot open /Users/dspitzer/FooAndBar/test/UnitTest++/src/Checks.h for reading!
How do I tell lcov and genhtml where the .cpp and .h files are?
Lcov is a graphical front-end for gcov. It collects gcov data for multiple source files and creates HTML pages containing the source code annotated with coverage information. It also adds overview pages for easy navigation within the file structure. Lcov supports statement, function, and branch coverage measurement.
Use the -b
option to lcov
. The -b
option specifies code base.
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