Question

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 targets build into different places, so the object files, .gcno and .gcda files are separate. Not all source files are compiled into the unit test, so not all objects will exist there. All source files are compiled into the product build.

Is there a way to combine the two sets of .gcda files to get the total coverage for unit tests and integration tests (as they are run on the product build)?

I'm using lcov.

Mac OS X 10.6, GCC 4.0

Thanks!

Was it helpful?

Solution

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.

OTHER TIPS

Finally I managed to solve my problem by means of lcov.

Basically what I did is the following:

  • Compile the application with the flags -fprofile-arcs -ftest-coverage --coverage
  • Distribute the copy of the application to each node.
  • Execute the application in each node in parallel. (This step generates into the application directory in the access host the coverage information)
  • Let lcov make his work:
    • lcov --directory src/ --capture --output-file coverage_reports/app.info
  • Generate the html output:
    • genhtml -o coverage_reports/ coverage_reports/app.info

I hope this can be of help to someone.

I merge it by lcov multi -d parameters as below. It works.

lcov -c -d ./tmp/ -d ./tmp1/ -o ./tmp/coverage.info
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top