summaryrefslogtreecommitdiffstats
path: root/src/test/coverage.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/coverage.sh')
-rwxr-xr-xsrc/test/coverage.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/coverage.sh b/src/test/coverage.sh
new file mode 100755
index 000000000..76591719a
--- /dev/null
+++ b/src/test/coverage.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+set -e
+
+usage () {
+ printf '%s: usage: %s [-d srcdir] [-o output_basename] COMMAND [ARGS..]\n' "$(basename "$0")" "$(basename "$0")" 1>&2
+ exit 1
+}
+
+OUTPUT_BASENAME=coverage
+SRCDIR=.
+
+while getopts "d:o:h" flag
+do
+ case $flag in
+ d) SRCDIR=$OPTARG;;
+ o) OUTPUT_BASENAME=$OPTARG;;
+ *) usage;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+
+lcov -d $SRCDIR -z > /dev/null 2>&1
+lcov -d $SRCDIR -c -i -o "${OUTPUT_BASENAME}_base_full.lcov" > /dev/null 2>&1
+"$@"
+lcov -d $SRCDIR -c -o "${OUTPUT_BASENAME}_tested_full.lcov" > /dev/null 2>&1
+lcov -r "${OUTPUT_BASENAME}_base_full.lcov" /usr/include\* -o "${OUTPUT_BASENAME}_base.lcov" > /dev/null 2>&1
+lcov -r "${OUTPUT_BASENAME}_tested_full.lcov" /usr/include\* -o "${OUTPUT_BASENAME}_tested.lcov" > /dev/null 2>&1
+lcov -a "${OUTPUT_BASENAME}_base.lcov" -a "${OUTPUT_BASENAME}_tested.lcov" -o "${OUTPUT_BASENAME}.lcov" | tail -n 3