I use gcov for doing code coverage analysis with lcov for generating graphical output of coverage. This works well for code file where atleast some part of object file has been executed. I want to be able to track files which have not been executed at all. I suspect this has to do with .gcda files not being generated for these files. Is there a way to force the generation of .gcda file for all object files irrespective of execution?
- I want to do the same. I'm dealing with a codebase where the unit tests are compiled as individual executables for each namespace. I can compile each with coverage and I get results for the classes that are involved in the tests. But some files have not had unit tests created for them, so are left out of this. They don't even get compiled as part of the test compilation. What I want is to somehow generate an empty initial .gcda for any .cpp.Benedict– Benedict2014-06-19 14:56:50 +00:00Commented Jun 19, 2014 at 14:56
2 Answers
The procedure to do this is outlined here:
http://linux.die.net/man/1/lcov
Recommended procedure when capturing data for a test case:
create baseline coverage data file
lcov -c -i -d appdir -o app_base.infoperform test
appdir/testcreate test coverage data file
lcov -c -d appdir -o app_test.infocombine baseline and test coverage data
lcov -a app_base.info -a app_test.info -o app_total.info
2 Comments
--all switch seems to produce a similar effect to running a preliminary baseline capture.For all of your files that are correctly compiled and linked, there will be a .gcda file. If you see that there's a missing *.gcda file check to see if the *.gcno file exists. If it doesn't check to see if all of you Makefiles are correctly build with:
- -ftest-coverage : The .gcno notes file is generated when the source file is compiled with this
- -fprofile-arcs : .gcda count data file is generated when a program containing object files built with the GCC -fprofile-arcs option is executed.
More info on: https://gcc.gnu.org/onlinedocs/gcc/Gcov.html#Gcov