g++ - Is it possible to merge coverage data from two executables with gcov/gcovr? -


on 1 project, i'm running test cases on 3 different executables, compiled different options. depending on options, code paths taken or not. right now, i'm using coverage data 1 executable.

i'm using gcovr generate xml parsed sonar:

gcovr -x -b -r . --object-directory=debug/test > coverage_report.xml 

i have 3 sets of gcda , gcno files, don't know how generate global report of them.

is there way ?

assuming "compiled different options" mean compile such obtain different outputs after preprocessing, of lcov (as mentioned k0n3ru) able it. here's sample code in file sut.c:

#include "sut.h" #include <limits.h>  int foo(int a) { #if defined(add)     += 42; #endif #if defined(sub)     -= 42; #endif     return a; } 

with sut.h providing declaration of foo, , simple main in test.c, calls foo , prints results. then, sequence of commands able create total.info file 100% coverage sut.c:

> g++ --coverage -dadd test.c sut.c -o add.out > ./add.out > lcov -c -d . -o add.info   # save data .gdda/.gcno add.info > g++ --coverage -dsub test.c sut.c -o sub.out > ./sub.out > lcov -c -d . -o sub.info   # save again, time sub.info > lcov -a add.info -a sub.info -o total.info  # combine them total.info > genhtml total.info 

which sut.c shows following results:

enter image description here

edit (thanks gluttton reminding me of adding part): going total.info file in lcov format cobertura xml output should possible of "lcov cobertura xml converter" provided here (although have not tried that): https://github.com/eriwen/lcov-to-cobertura-xml

the fact merging of coverage information possible, however, not mean idea so: coverage, imo, has limited informative value regarding quality of test suite. merging coverage results different preprocessor outputs further decrease value.

this because possibilities developers learn scenarios have not considered reduced: using conditional compilation control structure , data flow of code can vary tremendously between preprocessor outputs - coverage information results 'overlaying' results test runs different preprocessor outputs can make meaningful interpretation of results impossible.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -