3

I am using lcov (version 1.14) and cobertura to generate a coverage analysis on our C++ code. (gcc version 4.9)

After modifying the code, the code coverage went down inexplicably. Although we did not touch or remove any tests.

For example, line coverage dropped from 2540/2987 to 1597/3082.

On the report, we can see that certain source files are completely not tested, although the corresponding tests are run and are successful.

The commands I'm running are

lcov --directory . --base-directory $BUILD_DIR --capture --output-file $BUILD_DIR/code-coverage.lcov --gcov-tool gcov492
lcov --remove $BUILD_DIR/code-coverage.lcov '*/usr/include/*' '*/thirdparty/*' '*/test/*' $EXTRA_EXCLUDE --output-file $BUILD_DIR/filtered-code-coverage.lcov
lcov_cobertura.py -d $BUILD_DIR/filtered-code-coverage.lcov -o $BUILD_DIR/coverage.xml -b /data$SRC_DIR

I am getting the following warning and wondering if this is the problem:

lcov: WARNING: negative counts found in tracefile /build_dir/code-coverage.lcov

Can anybody help me makes sense of what is going on? Is this a configuration issue? Or is the problem with the commands I'm calling? Or is it actually lcov who is not working properly?

ZeusCoder
  • 101
  • 2
  • 1
    Is `code-coverage.lcov` in plain text? It might be worth looking in there for negative counts to see if you can narrow the problem down to a specific file/directory. – 0x5453 Mar 11 '19 at 17:18
  • 2
    Note: `lcov`/`gcov` is fine to get a *rough* idea of coverage, but it's not 100% accurate (in my experience). Treat it as an approximate indication - *especially* for optimized builds. – Jesper Juhl Mar 11 '19 at 17:22
  • Hello @0x5453 thank you for the idea! In the code-coverage.lcov file, I can see the list of execution counts for each instrumented line. Some line has a negative execution count. For example "DA:198,-792956" How could this be? – ZeusCoder Mar 12 '19 at 10:41

0 Answers0