How to do code coverage with Gcovr 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 gcovr command to print a tabular report on the console
gcovr command to print a tabular report on the console6. Generating HTML reports
7. Open coverage.html file to browse the coverage report
coverage.html file to browse the coverage reportLast updated