2

我正在使用 lcov 和 genhtml 生成代码覆盖率报告。使用以下目录结构,我可以获取位于 tests/ 目录中的源文件的代码覆盖率,但无法获取 src/ 目录中 my_file.c 文件的代码覆盖率。

src/
   my_file.c
   my_file.h
tests/
   AllTests.c
   CuTest.c
   CuTest.h
   my_file_tests.c

   objects/
       AllTests.gcda
       AllTests.gcno
       AllTests.o
       CuTest.gcda
       CuTest.gcno
       CuTest.o
       my_file.gcda
       my_file.gcno
       my_file.o
       my_file_tests.gcda
       my_file_tests.gcno
       my_file_tests.o

从测试目录调用 lcov 命令:

lcov -b . --directory objects/ -c -o ./coverage/app.info

Capturing coverage data from objects/
Found gcov version: 4.4.3
Scanning objects/ for .gcda files ...
Found 4 data files in objects/
Processing objects/AllTests.gcda
Processing objects/my_file_test.gcda
Processing objects/CuTest.gcda
Processing objects/my_file.gcda
geninfo: WARNING: gcov did not create any files for /home/me/workspace/project/tests/objects/my_file.gcda!
Finished .info-file creation
4

1 回答 1

3

从 lcov 1.7 升级到 1.9 为我解决了这个问题。1.9 版可从http://ltp.sourceforge.net/coverage/lcov.php获得

于 2011-06-21T19:54:25.393 回答