2

I have lcov report of my c++ code on each of my integration tests. I would like to merge it in one global report, I know it is possible but it only adds up hit lines count. I wish to have the information about which test hit each line.

I dunno if there is a way instead of writing a script myself.

Thanks

amestin
  • 31
  • 1
  • 3

1 Answers1

2

You can use geninfo in combination with lcov to achieve something similar.

If you have both .gcno and .gcda files available then first we will need to generate .info files.

To generate .info files use :

geninfo "path for .gcda files" -b "path for the source files" -o ./coverage1.info

So this will generate .info for your first test. Similarly, generate .info for all of your tests.

Now you can use lcov to combine these info files and get a combined report. To do that use:

lcov --add-tracefile coverage1.info -a coverage2.info ...coverageN -o merged.info

Now you have combined .info file and you can use genhtml to generate a HTML report for better view.

genhtml merged.info -o CodeCoverage
VVish
  • 251
  • 4
  • 11
  • Just want to add that you can also specify --rc lcov_branch_coverage=1 to get the bracnch coverage (source: https://stackoverflow.com/questions/12360167/generating-branch-coverage-data-for-lcov) – Robbe Claessens Oct 22 '21 at 14:43