I have the same source files (C and Obj-C) being compiled into two targets: the unit test executable and the actual product (which then gets integration tested). The two tar
I merge it by lcov multi -d parameters as below. It works.
lcov -c -d ./tmp/ -d ./tmp1/ -o ./tmp/coverage.info
Since you're using lcov, you should be able to convert the gcov .gcda files into lcov files and merge them with lcov --add-tracefile
.
From manpage: Add contents of tracefile. Specify several tracefiles using the -a switch to combine the coverage data contained in these files by adding up execution counts for matching test and filename combinations.
Finally I managed to solve my problem by means of lcov.
Basically what I did is the following:
-fprofile-arcs -ftest-coverage --coverage
lcov --directory src/ --capture --output-file coverage_reports/app.info
genhtml -o coverage_reports/ coverage_reports/app.info
I hope this can be of help to someone.
I think the intended way to do this is not to combine the .gcda
files directly but to create independent coverage data files using
lcov -o unittests.coverage -c -d unittests
lcov -o integrationtests.coverage -c -d integrationtests
Each coverage data then represents one "run". You can of course create separate graphs or html views. But you can also combine the data using --add-tracefile
, -a
for short
lcov -o total.coverage -a unittests.coverage -a integrationtests.coverage
From the total.coverage
you can generate the total report, using genhtml
for example.