Turns out that gcc comes with gcov.
1) Add the following option to the environment.
export CPPFLAGS="-fprofile-arcs -ftest-coverage"
2) Compile as normal
3) Run your tests.
4) gcov -l -c FileName.cpp
5) vi FileName.cpp.gcov and search for "######"
"######" indicate lines that were never executed.
It is simple and easy to use.
Here is an example of the output of gcov:
11: 9: for (i = 0; i < 10; i++)
10: 10: total += i;
-: 11:
1: 12: if (total != 45)
#####: 13: printf ("Failure\n");
-: 14: else
1: 15: printf ("Success\n");
Line #13 above was never executed. Line #9 was executed 11 times. You can also have it output percentages.
No comments:
Post a Comment