Как использовать lcov с флагом `--gcov-tool`? - PullRequest
0 голосов
/ 26 октября 2019

Я хочу использовать gcc, отличный от используемого по умолчанию в моей системе, для создания проекта. Поэтому мне нужно предоставить lcov правильную версию gcov-tool. К сожалению, флаг --gcov-tool у меня не работает. Даже с версией, которую lcov должен использовать по умолчанию.

Пример выполнения:

############## 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

1 Ответ

1 голос
/ 26 октября 2019

Я думаю, вы путаете двоичный файл gcov-tool с двоичным gcov.

- опция lcov для gcov-tool, ожидает двоичный gcov, а не двоичный gcov-tool

Для моей системы,двоичный файл gcov находится в той же папке, что и gcc

, который gcc

/usr/bin/gcc

, который gcov

/usr/bin/gcov

, который gcov-tool

/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
...