forked from koverstreet/ktest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coveragetool
executable file
·68 lines (51 loc) · 1.16 KB
/
coveragetool
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
set -o nounset
set -o errexit
ktest_out="./ktest-out"
usage()
{
echo "coveragetool: Generate lcov code profiling report"
echo "Usage: coveragetool [options]"
echo " -o <dir> output directory; defaults to ./ktest-out"
echo " -h display this help and exit"
}
while getopts "o:h" arg; do
case $arg in
o)
ktest_out=$OPTARG
;;
h)
usage
exit 0
;;
esac
done
shift $(( OPTIND - 1 ))
if [ "$#" -ne 0 ]; then
ktest_out=$1
else
ktest_out=./ktest-out
fi
ktest_out=$(readlink -f "$ktest_out")
if ! which lcov > /dev/null; then
echo "lcov not installed"
exit 0
fi
lcov_out="$ktest_out/lcov"
info=$lcov_out/lcov.info
html=$lcov_out/lcov.html
tracefiles=""
echo "lcov_out=$lcov_out"
mkdir -p "$lcov_out"
n=0
for dir in $ktest_out/gcov.*; do
out=$lcov_out/lcov.${n}.info
tracefiles+=" --add-tracefile $out"
lcov --capture --quiet --directory "$dir" --output-file "$out"
n=$((n+1))
done
[ -n "$tracefiles" ] || exit 0
lcov --quiet --output-file "$info" $tracefiles
genhtml --output-directory "$html" "$info"
echo
echo "LCOV report: file://$html/index.html"