blob: 6a1d8b8c15243f5762226a85e43a4bef3bde9502 (
plain)
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
|
# Copyright (C) 2005, 2007, 2012 INRIA
#
# This file is part of GNU MPC.
#
# GNU MPC is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# GNU MPC is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
# more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see http://www.gnu.org/licenses/ .
#!/bin/bash
# to compute the coverage of mpc-x.y.z, just copy this script
# into mpc-x.y.z/tools and run it
# Set up the right directoy
cd $(dirname $0)/..
# First Build MPC in /tmp/
echo "Erasing previous /tmp/ompc-gcov"
rm -rf /tmp/ompc-gcov
mkdir /tmp/ompc-gcov || exit 1
echo "Copying MPC sources to /tmp/ompc-gcov"
cp -r . /tmp/ompc-gcov || exit 1
cd /tmp/ompc-gcov || exit 1
echo "Remove previous coverage information."
rm -f $(find . -name '*.gc*')
echo "Reconfiguring MPC"
autoreconf -fi || exit 1
echo "Building MPC"
./configure --disable-shared --enable-static \
CFLAGS="--coverage -g" || exit 1
make clean || exit 1
make all -j4 || exit 1
# Note: we want to compute the coverage even in case of failure of some tests.
make check
# Check version of gcov:
# 3.3 outputs like this:
# 100.00% of 36 lines executed in function mpc_add
# 100.00% of 36 lines executed in file add.c
# Creating add.c.gcov.
# It doesn't support gcov *.c
#
# gcov (GCC) 3.4 outputs like this:
# Function `mpc_add'
# Lines executed:100.00% of 36
#
# File `add.c'
# Lines executed:100.00% of 36
# add.c:creating `add.c.gcov'
# It supports gcov *.c
# Setup the parser depending on gcov
version=$(gcov --version | head -1 | cut -f2 -d')')
version=$(( $(echo "$version" | cut -f1 -d'.')*100 + $(echo "$version" | cut -f1 -d'.')*10 ))
if test "$version" -ge 340 ; then
echo "#!/bin/bash
while true ; do
if read x ; then
case \$x in
Function*)
read y
case \$y in
*100.00*)
;;
*)
echo \$x \$y
;;
esac
;;
esac
else
exit 0
fi
done
" > coverage.subscript
else
echo "#!/bin/bash
while true ; do
if read x ; then
case \$x in
100.00*)
;;
*function*)
echo \$x
;;
esac
else
exit 0
fi
done
" > coverage.subscript
fi
# Do "gcov" for all files and parse the output
cd src
for i in $(find . -name '*.c')
do
gcov -f $i -o $(dirname $i) 2> /dev/null || exit 1
done | bash ../coverage.subscript | grep -v '__gmp' > ../coverage.mpc
rm -f coverage.subscript coverage-tmp || exit 1
cd -
lcov --rc lcov_branch_coverage=1 --capture --directory . --output-file all.info || exit 1
genhtml --branch-coverage -o coverage all.info || exit 1
echo "Coverage summary saved in file /tmp/ompc-gcov/coverage.mpc"
echo "Detailed coverage is available at /tmp/ompc-gcov/coverage/index.html"
|