Created
August 8, 2015 08:56
-
-
Save osamu0329nakamura/a9fa216cba4f100b8e28 to your computer and use it in GitHub Desktop.
kcovでラインカバレッジを収集する ref: http://qiita.com/osamu0329/items/7097fe0219675777c490
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int fib(int n) | |
{ | |
if (n <= 1) { | |
return 1; | |
} | |
return fib(n - 1) + fib(n - 2); | |
} | |
int main(int argc, char **argv) | |
{ | |
int n; | |
if (argc == 1) { | |
fprintf(stderr, "Usage\nfib n\n"); | |
exit(EXIT_FAILURE); | |
} | |
n = atoi(argv[1]); | |
printf("%d\n", fib(n)); | |
exit(EXIT_SUCCESS); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum install cmake | |
# yum install elfutils-libelf-devel elfutils-libs elfutils-devel | |
# yum install libcurl-devel | |
# yum install binutils-devel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd kcov-28 | |
$ mkdir build | |
$ cd cmake .. | |
$ make | |
$ sudo make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gcc -g fib.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kcov out-dir in-file [args...] | |
out-dir: カバレッジデータを出力するディレクトリ | |
in-file: カバレッジデータを収集する実行可能ファイル | |
args: in-fileのプログラム引数 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ kcov fib.out fib 10 | |
89 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ls kcov.out/index.html | |
kcov.out/index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ find . -name "*.xml" | |
./kcov.out/fib/cobertura.xml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment