summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorzimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2012-06-28 11:40:21 +0000
committerzimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2012-06-28 11:40:21 +0000
commitdccc01961014c5dfdb18a4556a8f2b65e1932263 (patch)
treee52e2489674adc473953cd52a92ba73c0ee6cf9d /tools
parentf1dcbf1f23362e19747f9b10bd54d730bbcb5134 (diff)
downloadmpc-dccc01961014c5dfdb18a4556a8f2b65e1932263.tar.gz
[tools] new directory
[tools/coverage] new script (adapted from MPFR) to produce coverage report git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@1201 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'tools')
-rwxr-xr-xtools/coverage105
1 files changed, 105 insertions, 0 deletions
diff --git a/tools/coverage b/tools/coverage
new file mode 100755
index 0000000..9fd4ca1
--- /dev/null
+++ b/tools/coverage
@@ -0,0 +1,105 @@
+#!/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="-fprofile-arcs -ftest-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 --capture --directory . --output-file all.info || exit 1
+genhtml -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"