I work in a C ++ Project with a structure similar to the following:
--- /src |--comms |--utils |--interfaces âĻ CMakeList.txt --- /test |---test1/ |--main.cpp |--CMakelists.txt --CMakeLists.txt
I need to control the coverage of my tests, and for this purpose I use GCOV and LCOV in this way:
Include coverage flags throughout CMakeLists.txt to generate .gcno files.
SET(CMAKE_CXX_FLAGS "-g -O0 -Wall -fprofile-arcs -ftest-coverage") SET(CMAKE_C_FLAGS "-g -O0 -Wall -W -fprofile-arcs -ftest-coverage") SET(CMAKE_EXE_LINKER_FLAGS "-fprofile-arcs -ftest-coverage")
Run the test by creating the corresponding .gcda files.
At this point, the gcno and gcda files are in the same directory as the corresponding .o file. I cannot move these files because if I do this, the report generation does not work.
In the directory where the .gcno and .gcda files are located, I do the following:
lcov âc âd . âo name.info
Create an HTML report using:
genhtml name.info.
When I compile my project, I have duplicate .gcno files due to the fact that when compiling the tests they need to recompile their dependencies (comms, utils, ...), because I do not create libraries for these dependencies. I think there is no way to avoid this if I do not use libraries.
However, when I try to create index.html (coverage report) for a global project, it does not work.
I use a shell script that creates the same folder structure of my project and copies each .gcno and .gcda to the corresponding directory. And I execute the lcov and genhtml , however index.html does not include the entire scope of the project.
I would appreciate any help.
source share