summaryrefslogtreecommitdiff
path: root/coverage
blob: e8df6d7802f7572057d2a3b9f18605665e1517c8 (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
#!/bin/bash

# First Build MPFR in /tmp/
echo "Erasing previous /tmp/ompfr-gcov"
rm -rf /tmp/ompfr-gcov
mkdir /tmp/ompfr-gcov
echo "Copying MPFR sources to /tmp/ompfr-gcov"
cp -r . /tmp/ompfr-gcov
cd /tmp/ompfr-gcov
echo "Building MPFR"
./configure --enable-assert --disable-shared --enable-static \
  CFLAGS="-fprofile-arcs -ftest-coverage -g"
make check -j2

# Check version of gcov:
# 3.3 outputs like this:
#  100.00% of 36 lines executed in function mpfr_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 `mpfr_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
gcov --version > coverage-tmp
if grep "gcov (GCC) 3.4" coverage-tmp ; 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
find . -name '*.c' -exec gcov -f '{}' ';' | \
  bash coverage.subscript > coverage.mpfr

rm -f coverage.subscript coverage-tmp
echo "Coverage summary saved in file /tmp/ompfr-gcov/coverage.mpfr"