summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2013-04-08 20:12:38 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2013-04-08 22:53:30 +0200
commitf44a46ba0ae88e159ddf7377a4e03102b8274b88 (patch)
treeba38e01ab587226f53509c859af7326a3ba467cb
parentdd1f0e5f1b4de00c98fe7444915864b7271e09fe (diff)
downloadcgit-upstream/jk/valgrind-tests.tar.gz
tests: add Valgrind supportupstream/jk/valgrind-tests
Now running tests with the "--valgrind" option will run cgit under Valgrind instead of all Git commands. Signed-off-by: John Keeping <john@keeping.me.uk>
-rwxr-xr-xtests/setup.sh37
-rwxr-xr-xtests/valgrind/bin/cgit12
2 files changed, 48 insertions, 1 deletions
diff --git a/tests/setup.sh b/tests/setup.sh
index 81e7220..f5a788e 100755
--- a/tests/setup.sh
+++ b/tests/setup.sh
@@ -15,12 +15,47 @@
# run_test 'repo index' 'cgit_url "/" | tidy -e'
# run_test 'repo summary' 'cgit_url "/foo" | tidy -e'
+# We don't want to run Git commands through Valgrind, so we filter out the
+# --valgrind option here and handle it ourselves. We copy the arguments
+# assuming that none contain a newline, although other whitespace is
+# preserved.
+LF='
+'
+test_argv=
+
+while test $# != 0
+do
+ case "$1" in
+ --va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind)
+ cgit_valgrind=t
+ test_argv="$test_argv${LF}--verbose"
+ ;;
+ *)
+ test_argv="$test_argv$LF$1"
+ ;;
+ esac
+ shift
+done
+
+OLDIFS=$IFS
+IFS=$LF
+set -- $test_argv
+IFS=$OLDIFS
+
: ${TEST_DIRECTORY=$(pwd)/../git/t}
TEST_NO_CREATE_REPO=YesPlease
. "$TEST_DIRECTORY"/test-lib.sh
# Prepend the directory containing cgit to PATH.
-PATH="$(pwd)/../..:$PATH"
+if test -n "$cgit_valgrind"
+then
+ GIT_VALGRIND="$TEST_DIRECTORY/valgrind"
+ CGIT_VALGRIND=$(cd ../valgrind && pwd)
+ PATH="$CGIT_VALGRIND/bin:$PATH"
+ export GIT_VALGRIND CGIT_VALGRIND
+else
+ PATH="$(pwd)/../..:$PATH"
+fi
mkrepo() {
name=$1
diff --git a/tests/valgrind/bin/cgit b/tests/valgrind/bin/cgit
new file mode 100755
index 0000000..dcdfbe5
--- /dev/null
+++ b/tests/valgrind/bin/cgit
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Note that we currently use Git's suppression file and there are variables
+# $GIT_VALGRIND and $CGIT_VALGRIND which point to different places.
+exec valgrind -q --error-exitcode=126 \
+ --suppressions="$GIT_VALGRIND/default.supp" \
+ --gen-suppressions=all \
+ --leak-check=no \
+ --track-origins=yes \
+ --log-fd=4 \
+ --input-fd=4 \
+ "$CGIT_VALGRIND/../../cgit" "$@"