How to do code coverage with Gcov tool
1. Prerequisites
2. Sample code
$ cat hello.c
#include <stdio.h>
void print_hello()
{
printf("Helloworld!!!");
return;
}
int main()
{
print_hello();
return 0;
}3. Compile source with --coverage or -fprofile-arcs -ftest-coverage flags
--coverage or -fprofile-arcs -ftest-coverage flags4. Run the user program
5. Run gcov tool to generate human readable coverage report
6. Generating HTML reports
1. Generate the coverage.info data file
2. Generate a report from this data file
3. Open index.html file to browse the coverage report
index.html file to browse the coverage reportLast updated