To use gcov we have to set the following compiler and linker flags (CMAKE):
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS="-fprofile-arcs -ftest-coverage")
After compiling you have to run the program and then call:
gcov sourcex.cpp.o
This creates a logfile called sourcefile.gcov.
Create HTML files of the coverage data:
lcov --directory . --capture --output-file app.info
lcov --directory . --capture --output-file app.info
Generate a HTML view:
genhtml app.info
No comments:
Post a Comment