-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcoverage.sh
executable file
·140 lines (117 loc) · 2.74 KB
/
coverage.sh
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#! /bin/bash
MYNAME=$(readlink -m $0)
MYDIR=$(dirname $MYNAME)
MYNAME=$(basename $MYNAME)
TESTARGS=""
NOCLEAN="no"
NOCONFIG="no"
TESTNAME=""
function printHelpAndExit
{
cat <<EOF
Usage: $MYNAME [OPTION]...
$MYNAME - Creates coverage information report for the project.
-h, --help Print help and exit.
--noclean Do not execute make clean/distclean.
--noconfig Do not execute autogen/configure.
--regen Just call lcov to regenerate the report.
--test=TEST Set the name of the unit test to perform.
--sqlpassword=pwd The SQL root password used for testing.
EOF
exit 1
}
#
# Processing command line options.
#
ARGS=$(getopt \
-o h \
-l "help,noclean,noconfig,regen,test:,sqlpassword:" \
-n "$MYNAME" -- "$@")
function execLcov
{
#
# Creating the report.
#
lcov \
--capture \
--directory . \
--directory libs9s/ \
--output-file coverage.info && \
lcov --remove coverage.info \
'/opt/*' '/usr/include/*' '*tests/*' \
--output-file $MYDIR/coverage_filtered.info && \
genhtml $MYDIR/coverage_filtered.info --output-directory $MYDIR/coverage
#firefox $MYDIR/coverage/src/index.html
}
eval set -- "$ARGS"
while true; do
case "$1" in
-h|--help)
shift
printHelpAndExit
;;
--noclean)
NOCLEAN="true"
shift
;;
--noconfig)
NOCONFIG="true"
shift
;;
--test)
shift
TESTNAME="$1"
shift
;;
--regen)
execLcov
exit 0
;;
--sqlpassword)
shift
TESTARGS="$TESTARGS --sqlpassword=$1"
shift
;;
--)
shift
break
;;
esac
done
if [ "$TESTNAME" ]; then
for testname in $(echo "$TESTNAME" | tr ',' ' '); do
if [ -x "$testname" ]; then
# There is perhaps a unit test with this name...
echo "Unit test with the name ${testname} found."
else
echo "No unit test with the name ${testname} found."
exit 1
fi
done
fi
if [ "$NOCLEAN" == "no" ]; then
make clean || true
make distclean || true
rm -fv */*.gcda */*.gcno */*/*.gcda */*/*.gcno
fi
if [ "$NOCONFIG" == "no" ]; then
./autogen.sh --enable-gcov
if [ $? -ne 0 ]; then
exit 1
fi
fi
make -j10
if [ $? -ne 0 ]; then
exit 1
fi
#
# Running the tests to create coverage data.
#
if [ "$TESTNAME" ]; then
for testname in $(echo "$TESTNAME" | tr ',' ' '); do
$testname/$testname $TESTARGS
done
else
tests/runalltests.sh $TESTARGS
fi
execLcov