]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
coverage: add helper script to get coverage for a local test
authorJosh Durgin <josh.durgin@dreamhost.com>
Mon, 6 Jun 2011 20:52:35 +0000 (13:52 -0700)
committerJosh Durgin <josh.durgin@dreamhost.com>
Tue, 7 Jun 2011 19:04:29 +0000 (12:04 -0700)
Signed-off-by: Josh Durgin <josh.durgin@dreamhost.com>
src/test/coverage.sh [new file with mode: 0755]

diff --git a/src/test/coverage.sh b/src/test/coverage.sh
new file mode 100755 (executable)
index 0000000..31b6e7e
--- /dev/null
@@ -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.info" > /dev/null 2>&1
+"$@"
+lcov -d $SRCDIR -c -o "${OUTPUT_BASENAME}_tested_full.info" > /dev/null 2>&1
+lcov -r "${OUTPUT_BASENAME}_base_full.info" /usr/include\* -o "${OUTPUT_BASENAME}_base.info" > /dev/null 2>&1
+lcov -r "${OUTPUT_BASENAME}_tested_full.info" /usr/include\* -o "${OUTPUT_BASENAME}_tested.info" > /dev/null 2>&1
+lcov -a "${OUTPUT_BASENAME}_base.info" -a "${OUTPUT_BASENAME}_tested.info" -o "${OUTPUT_BASENAME}.info" | tail -n 3