From: Sebastian Harl Date: Sun, 22 Dec 2013 17:53:53 +0000 (+0100) Subject: coverage.sh: Added a helper script to generate HTML coverage reports. X-Git-Tag: sysdb-0.1.0~277 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=175bbbff36c29b57866b378c187d690e889bb7c0;p=sysdb.git coverage.sh: Added a helper script to generate HTML coverage reports. The script uses lcov and creates a clean copy of the source code in a temporary directory using 'make dist'. --- diff --git a/coverage.sh b/coverage.sh new file mode 100755 index 0000000..a62f883 --- /dev/null +++ b/coverage.sh @@ -0,0 +1,58 @@ +#! /bin/bash +# +# SysDB -- coverage.sh +# +# Create a test coverage report for the System DataBase. + +set -e + +if ! which lcov || ! which genhtml; then + echo "lcov is required in order to generate a test coverage report" >&2 + exit 1 +fi + +cd $( dirname "$0" ) + +if test -e coverage; then + echo "coverage exists already; please remove manually" >&2 + exit 1 +fi + +V=$( grep '^PACKAGE_VERSION' Makefile | cut -d' ' -f3 ) +if test -z "$V"; then + echo "Unable to determine package version" >&2 + exit 1 +fi + +make dist + +tmpdir=$( mktemp -d -t ) +trap "rm -rf $tmpdir" EXIT + +srcdir=$( pwd ) + +cd $tmpdir +tar --strip-components=1 -zxf "$srcdir"/sysdb-$V.tar.gz +if test -d "$srcdir"/.git/; then + # copy Git database for version-gen.sh + cp -a "$srcdir"/.git . +fi + +./configure --enable-gcov --disable-shared CFLAGS="-O0 -g" +make + +V1=$( grep '^PACKAGE_VERSION' Makefile | cut -d' ' -f3 ) +if test -z "$V1"; then + # this should not happen + V1="$V" +fi + +lcov --base-directory src --directory src --zerocount +make test +lcov --base-directory src --directory src --no-external \ + --capture -o sysdb_coverage.info + +genhtml -o "$srcdir"/coverage \ + -t "SysDB $V1 test coverage" --num-spaces=4 --legend \ + sysdb_coverage.info +