Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

generating branch coverage data for lcov

Tags:

i'm trying to use lcov for code coverage metrics, but I cannot get branches coverage to work.

Here's how i'm using it:

g++ -ggdb3 --coverage src/read.c tests/test.cpp -o bin/test  lcov --zerocounters --directory $PWD  lcov --capture --initial --directory $PWD --output-file coverage_output   ./bin/test  lcov --no-checksum --directory $PWD --capture --output-file coverage_output  genhtml --branch-coverage --highlight --legend --output-directory out coverage_output 

but i get:

Overall coverage rate:
lines......: 100.0% (60 of 60 lines)
functions..: 100.0% (26 of 26 functions)
branches...: no data found

any ideas?

like image 576
Hugo Avatar asked Sep 10 '12 22:09

Hugo


2 Answers

The latest version of LCOV disabled branch coverage by default.

You need to re-enable it by either:

  • editing your ~/.lcovrc file (copied from /etc/lcovrc) to change lcov_branch_coverage setting to 1
  • adding --rc lcov_branch_coverage=1 to your lcov command lines
like image 108
Paul Rutland Avatar answered Sep 19 '22 14:09

Paul Rutland


.lcovrc files is file of settings that need to place in path of lcov file. Frankly, I didn't research much on use of this file.

You need to add additional parameter as "--rc lcov_branch_coverage=1" to lcov for all calls. In your case add this parameter to all your three calls. If you miss one, it will drop branch coverage.

Also --branch-coverage is needed for genhtml.

like image 43
Abhay Joshi Avatar answered Sep 23 '22 14:09

Abhay Joshi