Lcov: can not collect branch coverage statistics
Solution 1
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.)
Solution 2
the solution given above :
--rc lcov_branch_coverage=1
used both for lcov and genhtml, worked for me.
Related videos on Youtube
user1823629
Updated on September 15, 2022Comments
-
user1823629 over 1 year
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!
-
nwellnhof about 11 yearsPlease add the answer as an answer your own question. I found it very helpful.
-
Duncan Jones about 11 yearsI've added a community wiki answer below. If the author ever returns to this question, he/she can add their own answer and bask in the rewards.
-
Hcorg about 8 yearsPossible duplicate of generating branch coverage data for lcov
-