Kuldeep Kumar
Kuldeep Kumar

Reputation: 11

Incorrect code coverage on every run using Gcovr

We are observing incorrect code coverage of C++ project on every run (Linux, Gcovr). Please find below our observations:

  1. All the object files, gcno, gcda, libraries are being generating.
  2. All the 147 test cases are getting passed successfully.
  3. There are 600+ files for which coverage is shown but for few files (0-15 files) only code coverage is always incorrect and for rest of the files coverage is always constant. For example: In one run code coverage is incorrect for 10 files in next run coverage is incorrect for 14 files.
  4. For one file we have observed 0% code coverage but we found that the functions of that files are getting successfully called.

Also, there is a difference in the number of lines and branches in the total count highlighted in the attached pictures.

enter image description here enter image description here

As per our understanding the total number of lines and branches should be constant because they are calculated at the compilation time (flag used -fPIC -fprofile-arcs -ftest-coverage) and should be in gcno files. Please correct, if our understanding is wrong.

Why there is a difference in the total number of lines and branches count?

If all the binaries are getting generated and all the testcases are successfully executed. What could be cause of incorrect code coverage of few files only every time?

How we can correct our code coverage?

Note: Its a C++ client project. We checked the behavior with other projects also but out of 6 projects, 4 projects are working fine with no code coverage issues.

Upvotes: 0

Views: 75

Answers (0)

Related Questions