0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

clangでビルドしてlcovでカバレッジを取る方法

Posted at

内容

  • lcovはgcc用のライブラリなので、clangでビルドしたgcdaファイルをlcovでそのまま変換しようとすると以下のエラーがでる。
$ lcov -c -d ./build -o lcov.info
Capturing coverage data from ./build
Found gcov version: 7.5.0
Scanning ./build for .gcda files ...
Found 7 data files in ./build
Processing src/CMakeFiles/src.dir/my_thread.cpp.gcda
/home/xxxx/git-work/wsl-ci-env/build/src/CMakeFiles/src.dir/my_thread.cpp.gcno:version '402*', prefer 'A75*'
geninfo: ERROR: GCOV failed for /home/xxxx/git-work/wsl-ci-env/build/src/CMakeFiles/src.dir/my_thread.cpp.gcda!

このエラーを回避してカバレッジを取る方法の記事

参考

基本はこの方法で可能だが、そのままだとエラーがでるところがあったので少し修正している。

前提

  • Ubuntu上での実行
  • gcc と lcovの使い方は知っている

手順

LLVMインストール

$ sudo apt install llvm

llvm-gcov.shを以下の内容で作成する

llvm-gcov.sh
#!/bin/bash
exec llvm-cov gcov "$@"

$ chomod +x llvm-gcov.sh で実行ファイルにする

--gcov-toolオプションで実行する

$ lcov -c -d ./build -o lcov.info --gcov-tool `pwd`/llvm-gcov.sh
Capturing coverage data from ./build
Found LLVM gcov version 6.0.0, which emulates gcov version 4.2.0
Scanning ./build for .gcda files ...
Found 7 data files in ./build
Processing src/CMakeFiles/src.dir/my_thread.cpp.gcda
...
Finished .info-file creation
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?