2

I'm trying to get coverage information for each of my test cases (and also the total coverage). But since .gcda file will be merged everytime the program runs, it's not possible unless the file is deleted/moved.

The problem of deleting the .gcda file for every new test case execution is that I have to repeat the whole process again in order to get the coverage information of all of my test cases. If I have 2000 test cases, I have to run my program 4000 times.

As for moving the .gcda file, I have to merge all of the .gcda files. Is it possible to merge multiple gcda files with Gcov (or Gcovr since I use it for the XML output)?

Apparently lcov has a merging feature but AFAIK it doesn't support xml output.

yugr
  • 19,769
  • 3
  • 51
  • 96
AceVez
  • 291
  • 1
  • 5
  • 19
  • 2
    I think `gcov-tool merge` can merge profiling data from two directories, but I'm not sufficiently familiar with it to write an answer. Note that gcov-tool seems to be younger than the question you linked. – amon Mar 13 '18 at 18:07
  • @amon it works! I'm surprised I didn't get `gcov-tool` on any of my search result. it's quite simple to use but there are a couple of things that are not really clear to me like "weight factor" or "online/offline generated". Mind if you put it as your answer so I can accept it? – AceVez Mar 14 '18 at 03:56
  • You can self-answer with your experiences, or write an answer to the question you linked. This question can then be closed as a duplicate. – amon Mar 14 '18 at 12:06

1 Answers1

0

gcov can merge coverage data from two runs with the help of gcov-tool:

$ gcov-tool merge dir1 dir2

(by default results will be stored into merged_profile folder).

One problem with gcov-tool is that it can only be applied to two directories at a time (whereas you seem to have thousands). You can use the gcov-tool-many wrapper to work around this.

yugr
  • 19,769
  • 3
  • 51
  • 96