Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can lcov/genhtml show files that were never executed?

How can I make lcov and genhtml show files that are not linked / loaded? I'm using it to show test coverage and I would like to see every source file appear in the HTML report, even if it has zero coverage. That way I can use lcov to identify source files that are missing tests. The missing source files have a .gcno file created for them, but not a .gcda file.

like image 203
Evan Avatar asked May 26 '17 13:05

Evan


1 Answers

If you want to see all files you have to create a baseline coverage data file with -i option. After capturing you data you have to combine the two files with -a option.

There is an example in lcov man page (https://linux.die.net/man/1/lcov):

Capture initial zero coverage data.

Run lcov with -c and this option on the directories containing .bb, .bbg or .gcno files before running any test case. The result is a "baseline" coverage data file that contains zero coverage for every instrumented line. Combine this data file (using lcov -a) with coverage data files captured after a test run to ensure that the percentage of total lines covered is correct even when not all source code files were loaded during the test.

Recommended procedure when capturing data for a test case:

  1. create baseline coverage data file

    lcov -c -i -d appdir -o app_base.info

  2. perform test

    appdir/test

  3. create test coverage data file

    lcov -c -d appdir -o app_test.info

  4. combine baseline and test coverage data

    lcov -a app_base.info -a app_test.info -o app_total.info

You then have to use the app_total.info as source for genhtml.

like image 173
Julian Mayer Avatar answered Sep 22 '22 06:09

Julian Mayer