我如何告诉lcov在哪里找到.cpp和.h文件?

问题描述 投票:11回答:2

我的源代码和构建树在生成(构建并运行FooAndBarTests)之后看起来像这样(请参阅Makefile to put object files from source files different directories into a single, separate directory?

src
- Foo.cpp
- Bar.cpp
inc
- Foo.h
- Bar.h
test
- FooTest.cpp
- BarTest.cpp
- Main.cpp
- Makefile
- obj
  - Foo.gcda
  - Foo.gcno
  - Bar.gcda
  - Bar.gcno
- FooAndBarTests
UnitTest++
- libUnitTest++.a
- src
  - ...

然后我可以通过运行gcov -o obj/ ../src/Foo.cppgcov -o obj/ ../src/Bar.cpp在测试目录中生成.gcov文件。

但是如果我运行lcov -d obj/ -c -o FooAndBarTests.lcov,我会得到:

Capturing coverage data from obj/
Found gcov version: 4.2.1
Scanning obj/ for .gcda files ...
Found 4 data files in obj/
Processing Foo.gcda
../src/Foo.cpp:cannot open source file
Processing FooTest.gcda
FooTest.cpp:cannot open source file
../inc/Foo.h:cannot open source file
../UnitTest++/src/Checks.h:cannot open source file
...

然后我运行genhtml FooAndBarTests.lcov时得到:

Reading data file FooAndBarTests.lcov
Found 45 entries.
Found common filename prefix "/Users/dspitzer/FooAndBar/test"
Writing .css and .png files.
Generating output.
Processing file UnitTest++/src/Checks.h
genhtml: ERROR: cannot open /Users/dspitzer/FooAndBar/test/UnitTest++/src/Checks.h for reading!

我如何告诉lcov和genhtml .cpp和.h文件在哪里?

c++ code-coverage gcov lcov unittest++
2个回答
14
投票

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.