【问题标题】:Lcov: can not collect branch coverage statisticsLcov:无法收集分支覆盖率统计信息
【发布时间】:2012-11-02 22:31:12
【问题描述】:

我使用lcov 在我的项目中创建覆盖信息。但我只能得到线路覆盖率和功能覆盖率统计信息。

lcov version:1.10, gcov version:4.4.5

我使用的命令是:

 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

经过这两条命令,我得到的结果是:

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**

所以没有分支覆盖结果。为什么?所以发生了什么事?这怎么可能发生?我在这里很困惑。

在第一个命令之后,我收到了很多这样的警告:

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!

【问题讨论】:

  • 请将答案添加为您自己的问题的答案。我发现它很有帮助。
  • 我在下面添加了一个社区 wiki 答案。如果作者再次回到这个问题,他/她可以添加自己的答案并享受奖励。

标签: c testing branch code-coverage lcov


【解决方案1】:

我收到了来自 geninfo 的作者 Peter Oberparleiter 的电子邮件。我得到的答案如下。

LCOV 1.10 默认禁用分支覆盖。您可以通过修改 lcovrc 文件(参见man lcovrc)或在运行lcov/genhtml 时指定--rc lcov_branch_coverage=1 来启用它。

如果您没有使用 LCOV 1.10 并且仍然没有获得分支覆盖,则可能是您的 GCC 版本没有提供此信息。

(上面的答案被the author错误地添加到问题中。)

【讨论】:

    【解决方案2】:

    上面给出的解决方案:

    --rc lcov_branch_coverage=1
    

    同时用于 lcov 和 genhtml,对我有用。

    【讨论】:

      猜你喜欢
      • 2012-09-03
      • 2014-11-09
      • 2017-01-09
      • 2017-03-31
      • 2017-05-15
      • 2022-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多