Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lcov: can not collect branch coverage statistics

Tags:

I used the lcov to create coverage information in my project. But I only can get line coverage and function coverage statistics information.

lcov version:1.10, gcov version:4.4.5 

The commands I used is:

 lcov -d $OSPL_HOME/src -d $OSPL_OUTER_HOME/src  -c -o /work/li/log/lcov-raw.info  lcov -r /work/li/log/lcov-raw.info "*.ll" "*.yy" "*.yy.c" yaccpar "TAO161*" "/usr/include/*"  "*/testsuite/*" -o /work/li/log/lcov.info 

After these two commands, I got the results is:

Deleted 23 files  Writing data to /work/li/log/lcov.info  Summary coverage rate:    lines......: 45.4% (65087 of 143496 lines)     functions..: 46.1% (5575 of 12102 functions)    **branches...: no data found** 

So there were no branches coverage results. Why? So what happened? And how can this happen? I am confused here.

After the first command, I got lots of warnings like these:

geninfo: WARNING: cannot find an entry for ..#..#code#accum.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#at.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#autodef.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#copyof.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#debug.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#define.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#dump.c.gcov in .gcno file,skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#error.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#expand.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#expr.c.gcov in .gcno file,skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#if.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#include.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#io.c.gcov in .gcno file, s kipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#is.c.gcov in .gcno file, s kipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#line.c.gcov in .gcno file,skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#pragma.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#preprocess.c.gcov in .gcnofile, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#set.c.gcov in .gcno file,skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#sharp.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#symtbl.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#undef.c.gcov in .gcno file, skipping file!  geninfo: WARNING: cannot find an entry for ..#..#code#while.c.gcov in .gcno file , skipping file! 
like image 741
user1823629 Avatar asked Nov 14 '12 12:11

user1823629


People also ask

How do I get branch coverage in LCOV?

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.

How is branch coverage calculated?

To calculate Branch Coverage, one has to find out the minimum number of paths which will ensure that all the edges are covered. In this case there is no single path which will ensure coverage of all the edges at once. The aim is to cover all possible true/false decisions.

What is LCOV report?

LCOV is a graphical tool for GCC's coverage testing with gcov. It creates HTML pages containing the source code annotated with coverage information by collecting gcov data from multiple source files. LCOV supports “Lines coverage” and “Functions coverage” measurement.


1 Answers

I got the email from Peter Oberparleiter, the author of geninfo. I got the answer as following.

LCOV 1.10 has branch coverage disabled per default. You can enable it by modifying the lcovrc file (see man lcovrc) or by specifying --rc lcov_branch_coverage=1 when running lcov/genhtml.

If you're not using LCOV 1.10 and still don't get branch coverage, it may be that you're version of GCC does not provide this information.

(The above answer was erroneously added to the question by the author.)

like image 200
2 revs Avatar answered Sep 23 '22 19:09

2 revs