-
Notifications
You must be signed in to change notification settings - Fork 38
Running the GCC Coverage Tool
Siavash Zangeneh edited this page Apr 28, 2022
·
1 revision
Based on the example from here.
(python3) [siavash@pool5 coverage]$ g++ -fprofile-arcs -ftest-coverage test.cpp
(python3) [siavash@pool5 coverage]$ ls
a.out test.cpp test.gcno
(python3) [siavash@pool5 coverage]$ ./a.out
(python3) [siavash@pool5 coverage]$ ls
a.out test.cpp test.gcda test.gcno
(python3) [siavash@pool5 coverage]$ gcov test.c
File 'test.cpp'
Lines executed:83.33% of 6
Creating 'test.cpp.gcov'
(python3) [siavash@pool5 coverage]$ cat test.cpp
int main(int argc, char**argv) {
int x = 0;
if (argc > 1) {
x = 1;
} else {
x = 2;
}
return x;
}