With gcov, is it possible to merge to .gcda files?

后端 未结 4 1354
走了就别回头了
走了就别回头了 2020-12-09 20:58

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

相关标签:
4条回答
  • 2020-12-09 21:29

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

    lcov -c -d ./tmp/ -d ./tmp1/ -o ./tmp/coverage.info
    
    0 讨论(0)
  • 2020-12-09 21:36

    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.

    0 讨论(0)
  • 2020-12-09 21:37

    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.

    0 讨论(0)
  • 2020-12-09 21:38

    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.

    0 讨论(0)
提交回复
热议问题