如何将 lcov 与 `--gcov-tool` 标志一起使用?
How to use lcov with `--gcov-tool` flag?
我想使用与系统默认设置不同的 gcc 来构建项目。因此我需要为 lcov 提供正确的 gcov-tool 版本。不幸的是 --gcov-tool
标志对我不起作用。即使是版本 lcov 也应该默认为。
- 塔维斯 运行: https://travis-ci.org/extcpp/libext/jobs/603195448
- 拉请求:https://github.com/extcpp/libext/pull/9
- 覆盖脚本:https://github.com/extcpp/libext/blob/coverage/support/coverage
样本运行:
############## extract test coverage ##############
g++-8 (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gcov-tool-8 (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
+ echo 'will work!'
will work!
+ lcov --capture --directory /data/home/extcpp/repos/extcpp/libext-build/debug --output-file test_coverage.info
Capturing coverage data from /data/home/extcpp/repos/extcpp/libext-build/debug
Found gcov version: 8.3.0
Scanning /data/home/extcpp/repos/extcpp/libext-build/debug for .gcda files ...
Found 25 data files in /data/home/extcpp/repos/extcpp/libext-build/debug
Processing CMakeFiles/ext_shared.dir/src/logging.cpp.gcda
Processing external_libs/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.gcda
Processing tests/CMakeFiles/test_libext_shared.dir/logging.cpp.gcda
Processing tests/CMakeFiles/test_libext_shared.dir/gtest.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_cast.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/math.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/algorithm_knapsack.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_enum.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_serialization.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_lazy.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_encode.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/meta_is_one_of.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_endian.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_result.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_scoped_timer.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_except.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_string.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/algorithm_string_distances.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_any_printable.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/gtest.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/meta_if.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_basic.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_windows_strings.cpp.gcda
geninfo: WARNING: gcov did not create any files for /data/home/extcpp/repos/extcpp/libext-build/debug/tests/CMakeFiles/test_libext.dir/util_windows_strings.cpp.gcda!
Processing tests/CMakeFiles/test_libext.dir/algorithm_basic.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/meta_has_member.cpp.gcda
Finished .info-file creation
+ echo 'will fail!'
will fail!
++ type -p gcov-tool-8
+ lcov --capture --directory /data/home/extcpp/repos/extcpp/libext-build/debug --gcov-tool /usr/bin/gcov-tool-8 --output-file test_coverage.info
Capturing coverage data from /data/home/extcpp/repos/extcpp/libext-build/debug
Found gcov version: 8.3.0
Scanning /data/home/extcpp/repos/extcpp/libext-build/debug for .gcda files ...
Found 25 data files in /data/home/extcpp/repos/extcpp/libext-build/debug
Processing CMakeFiles/ext_shared.dir/src/logging.cpp.gcda
Usage: gcov-tool-8 [OPTION]... SUB_COMMAND [OPTION]...
Offline tool to handle gcda counts
-h, --help Print this help, then exit
-v, --version Print version number, then exit
merge [options] <dir1> <dir2> Merge coverage file contents
-o, --output <dir> Output directory
-v, --verbose Verbose mode
-w, --weight <w1,w2> Set weights (float point values)
rewrite [options] <dir> Rewrite coverage file contents
-n, --normalize <int64_t> Normalize the profile
-o, --output <dir> Output directory
-s, --scale <float or simple-frac> Scale the profile counters
-v, --verbose Verbose mode
overlap [options] <dir1> <dir2> Compute the overlap of two profiles
-f, --function Print function level info
-F, --fullname Print full filename
-h, --hotonly Only print info for hot objects/functions
-o, --object Print object level info
-t <float>, --hot_threshold <float> Set the threshold for hotness
-v, --verbose Verbose mode
For bug reporting instructions, please see:
<file:///usr/share/doc/gcc-8/README.Bugs>.
geninfo: ERROR: GCOV failed for /data/home/extcpp/repos/extcpp/libext-build/debug/CMakeFiles/ext_shared.dir/src/logging.cpp.gcda!
+ ferr 'failed to extract coverage'
+ echo 'failed to extract coverage'
failed to extract coverage
+ exit 1
我认为您混淆了 gcov-tool binary 和 gcov binary。
--lcov 的 gcov-tool 选项,需要 gcov 二进制而不是 gcov-tool 二进制
对于我的系统,gcov 二进制文件存在于与 gcc 相同的文件夹中
哪个gcc
/usr/bin/gcc
哪个gcov
/usr/bin/gcov
哪个gcov工具
/usr/bin/gcov-tool
所以对我来说
lcov --capture --directory /home/user/mydir
相当于
lcov --capture --directory /home/user/mydir --gcov-tool /usr/bin/gcov
下面是不正确的(这就是你想要做的)
lcov --capture --directory /home/user/mydir --gcov-tool /usr/bin/gcov-tool
我想使用与系统默认设置不同的 gcc 来构建项目。因此我需要为 lcov 提供正确的 gcov-tool 版本。不幸的是 --gcov-tool
标志对我不起作用。即使是版本 lcov 也应该默认为。
- 塔维斯 运行: https://travis-ci.org/extcpp/libext/jobs/603195448
- 拉请求:https://github.com/extcpp/libext/pull/9
- 覆盖脚本:https://github.com/extcpp/libext/blob/coverage/support/coverage
样本运行:
############## extract test coverage ##############
g++-8 (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gcov-tool-8 (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
+ echo 'will work!'
will work!
+ lcov --capture --directory /data/home/extcpp/repos/extcpp/libext-build/debug --output-file test_coverage.info
Capturing coverage data from /data/home/extcpp/repos/extcpp/libext-build/debug
Found gcov version: 8.3.0
Scanning /data/home/extcpp/repos/extcpp/libext-build/debug for .gcda files ...
Found 25 data files in /data/home/extcpp/repos/extcpp/libext-build/debug
Processing CMakeFiles/ext_shared.dir/src/logging.cpp.gcda
Processing external_libs/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.gcda
Processing tests/CMakeFiles/test_libext_shared.dir/logging.cpp.gcda
Processing tests/CMakeFiles/test_libext_shared.dir/gtest.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_cast.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/math.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/algorithm_knapsack.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_enum.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_serialization.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_lazy.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_encode.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/meta_is_one_of.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_endian.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_result.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_scoped_timer.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_except.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_string.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/algorithm_string_distances.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_any_printable.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/gtest.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/meta_if.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_basic.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/util_windows_strings.cpp.gcda
geninfo: WARNING: gcov did not create any files for /data/home/extcpp/repos/extcpp/libext-build/debug/tests/CMakeFiles/test_libext.dir/util_windows_strings.cpp.gcda!
Processing tests/CMakeFiles/test_libext.dir/algorithm_basic.cpp.gcda
Processing tests/CMakeFiles/test_libext.dir/meta_has_member.cpp.gcda
Finished .info-file creation
+ echo 'will fail!'
will fail!
++ type -p gcov-tool-8
+ lcov --capture --directory /data/home/extcpp/repos/extcpp/libext-build/debug --gcov-tool /usr/bin/gcov-tool-8 --output-file test_coverage.info
Capturing coverage data from /data/home/extcpp/repos/extcpp/libext-build/debug
Found gcov version: 8.3.0
Scanning /data/home/extcpp/repos/extcpp/libext-build/debug for .gcda files ...
Found 25 data files in /data/home/extcpp/repos/extcpp/libext-build/debug
Processing CMakeFiles/ext_shared.dir/src/logging.cpp.gcda
Usage: gcov-tool-8 [OPTION]... SUB_COMMAND [OPTION]...
Offline tool to handle gcda counts
-h, --help Print this help, then exit
-v, --version Print version number, then exit
merge [options] <dir1> <dir2> Merge coverage file contents
-o, --output <dir> Output directory
-v, --verbose Verbose mode
-w, --weight <w1,w2> Set weights (float point values)
rewrite [options] <dir> Rewrite coverage file contents
-n, --normalize <int64_t> Normalize the profile
-o, --output <dir> Output directory
-s, --scale <float or simple-frac> Scale the profile counters
-v, --verbose Verbose mode
overlap [options] <dir1> <dir2> Compute the overlap of two profiles
-f, --function Print function level info
-F, --fullname Print full filename
-h, --hotonly Only print info for hot objects/functions
-o, --object Print object level info
-t <float>, --hot_threshold <float> Set the threshold for hotness
-v, --verbose Verbose mode
For bug reporting instructions, please see:
<file:///usr/share/doc/gcc-8/README.Bugs>.
geninfo: ERROR: GCOV failed for /data/home/extcpp/repos/extcpp/libext-build/debug/CMakeFiles/ext_shared.dir/src/logging.cpp.gcda!
+ ferr 'failed to extract coverage'
+ echo 'failed to extract coverage'
failed to extract coverage
+ exit 1
我认为您混淆了 gcov-tool binary 和 gcov binary。
--lcov 的 gcov-tool 选项,需要 gcov 二进制而不是 gcov-tool 二进制
对于我的系统,gcov 二进制文件存在于与 gcc 相同的文件夹中
哪个gcc
/usr/bin/gcc
哪个gcov
/usr/bin/gcov
哪个gcov工具
/usr/bin/gcov-tool
所以对我来说
lcov --capture --directory /home/user/mydir
相当于
lcov --capture --directory /home/user/mydir --gcov-tool /usr/bin/gcov
下面是不正确的(这就是你想要做的)
lcov --capture --directory /home/user/mydir --gcov-tool /usr/bin/gcov-tool