4

在更新到 Ubuntu 16.04 后,我正在尝试对我的项目进行报道。我明白了

Deleted 665 files
Writing data to coverage.info.cleaned
lcov: ERROR: cannot write to coverage.info.cleaned!
CMakeFiles/coverage.dir/build.make:57: recipe for target 'CMakeFiles/coverage' failed
make[3]: *** [CMakeFiles/coverage] Error 13
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/coverage.dir/all' failed
make[2]: *** [CMakeFiles/coverage.dir/all] Error 2
CMakeFiles/Makefile2:74: recipe for target 'CMakeFiles/coverage.dir/rule' failed
make[1]: *** [CMakeFiles/coverage.dir/rule] Error 2
Makefile:129: recipe for target 'coverage' failed
make: *** [coverage] Error 2
enter code here

在更新之前,我运行覆盖没有问题

4

1 回答 1

5

如果在将文件传递到时使用绝对路径而不是相对路径lcov,它会有所帮助吗?

我遇到了一个类似的问题,lcov也无法写入文件。不确定这是否是 中的错误lcov,但问题是它与相对路径混淆了:

lcov -a test_fast_cxxtest_gcov__base.info -a test_fast_cxxtest_gcov__test.info \
     -o test_fast_cxxtest_gcov__total.info
Combining tracefiles.
Reading tracefile test_fast_cxxtest_gcov__base.info
Reading tracefile test_fast_cxxtest_gcov__test.info
lcov: WARNING: function data mismatch at /home/phil/ghost/constants.h:1862
Writing data to test_fast_cxxtest_gcov__total.info
lcov: ERROR: cannot write to test_fast_cxxtest_gcov__total.info!

运行它strace显示它chdir("/")在多个位置执行,这会将工作目录更改为/. 这就解释了为什么它不能写入文件。

一种解决方法是使用绝对路径。例如,如果您使用 GNU make,您可以使用以下abspath命令:

lcov -a $(abspath test_fast_cxxtest_gcov__base.info) \
     -a $(abspath test_fast_cxxtest_gcov__test.info) \
     -o $(abspath test_fast_cxxtest_gcov__total.info)

更改之后,它终于能够写入文件。

(据我所见,尝试使用--base-directoryor选项设置目录等其他选项--directory没有效果。lcov我测试的版本是 1.12。)

问题不仅限于 Ubuntu,因为我在 Arch Linux 上遇到了它。但是,它可能是 1.12 中引入的回归,所以我报告了它(参见问题 #77630)。

更新: Lcov 不是 GCC 的一部分,所以我的原始错误报告已关闭,但我从 Lcov 邮件列表中得到了答复。该问题已在提交632c25中修复。基于 Arch Linux 的发行版的用户可以使用aur/lcov-git尝试最新的快照。

于 2016-09-17T22:53:10.497 回答