Tuesday, June 10, 2014

Code coverity using GCC gcov



Create a cpp source file with main function and name it main.cpp

Build source with gcov enabled
g++ -Wall -fprofile-arcs -ftest-coverage main.cpp
                It will generate main.gcno file
Run binary
                ./a.out
                It will generate main.gcda file
Run gcov for the source file
                gcov main.cpp
                it will generate main.cpp.gcov file
Open main.cpp.gcov and analyse ##### lines for un tested code lines.