首页 > 解决方案 > 源和对象位于不同目录时的覆盖率报告

问题描述

我正在尝试为我的项目生成覆盖率报告并遇到问题。

我知道要获得覆盖信息,我需要 .gcno、.gcda 和源文件。我当前的项目目录结构是

/root/proj/src   --> top level Makefile and main.c
    /root/proj/src/module1
    /root/proj/src/module2
    .....                  -> contains all .c/.h ,makefile  
/root/proj/build/obj -> contains  all .o,.gcno,.gcda files after compilation 
/root/proj/build/exe  -> contains the executable 

(复制下面的最少行以显示问题)

cd /root/proj/build/obj

当我跑步时

lcov -b ../../src/ --directory . --capture --output-file app.info
Processing module1.gcda
module1.c:cannot open source file

...... 

Finished .info-file creation 

然后 :

genhtml --legend   -o ./latest_code_cov/ app.info
Reading data file app.info
Found 5 entries.
Found common filename prefix "/root/proj/src"
Writing .css and .png files.
Generating output.
Processing file src/module1.c
genhtml: ERROR: cannot read /root/proj/src/module1.c
bash-4.1$

1) 我是否需要更改我的 makefile 以将文件转储.gcno/.gcda到与源相同的文件夹中?

2)有没有办法(一些标志)在文件中设置源文件路径.gcno/.gcda

有什么建议么?

gcc 版本 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC)

lcov:LCOV 1.13 版

标签: code-coveragelcov

解决方案


推荐阅读