Home ->
Unix Programming Tools
gcov is a standard Linux code coverage testing tool. This tool lets you see how many times each line of your code has been executed since it was compiled. The purpose of this is to help you develop better testing cases by looking for any areas of your code that have not been reached by your tests.
Example output of gcov:
kandrea@zeus-1:~$ gcov c_test
File 'c_test.c'
Lines executed:80.00% of 5
Creating 'c_test.c.gcov'
kandrea@zeus-1:~$
gcov
tool, which will generate the above output and an accompanying file, as shown below:
kandrea@zeus-1:~$ cat c_test.c.gcov
-: 0:Source:c_test.c
-: 0:Graph:c_test.gcno
-: 0:Data:c_test.gcda
-: 0:Runs:3
-: 0:Programs:1
-: 1:#include
-: 2:
3: 3:int main(int argc, char **argv) {
3: 4: if(argc == 1) {
2: 5: printf("No Args!\n");
-: 6: } else {
1: 7: printf("Args!\n");
-: 8: }
3: 9: return 0;
-: 10:}
kandrea@zeus-1:~$