diff options
author | John Keeping | 2013-04-08 20:12:38 +0100 |
---|---|---|
committer | Jason A. Donenfeld | 2014-01-12 19:33:03 +0100 |
commit | 1b1974c45e5e23e5527aa43c4d9ece423a13dfdc (patch) | |
tree | 863ba37c8c25b917e1823ec10db6600a9b41e129 /tests | |
parent | 382ecf152e1bd9546f6c84ace71c62ca07f6648b (diff) | |
download | cgit-1b1974c45e5e23e5527aa43c4d9ece423a13dfdc.tar.gz cgit-1b1974c45e5e23e5527aa43c4d9ece423a13dfdc.tar.bz2 cgit-1b1974c45e5e23e5527aa43c4d9ece423a13dfdc.zip |
tests: add Valgrind support
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>
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/setup.sh | 37 | ||||
-rwxr-xr-x | tests/valgrind/bin/cgit | 12 |
2 files changed, 48 insertions, 1 deletions
diff --git a/tests/setup.sh b/tests/setup.sh index 1d8677a..5476ced 100755 --- a/tests/setup.sh +++ b/tests/setup.sh | |||
@@ -15,13 +15,48 @@ | |||
15 | # run_test 'repo index' 'cgit_url "/" | tidy -e' | 15 | # run_test 'repo index' 'cgit_url "/" | tidy -e' |
16 | # run_test 'repo summary' 'cgit_url "/foo" | tidy -e' | 16 | # run_test 'repo summary' 'cgit_url "/foo" | tidy -e' |
17 | 17 | ||
18 | # We don't want to run Git commands through Valgrind, so we filter out the | ||
19 | # --valgrind option here and handle it ourselves. We copy the arguments | ||
20 | # assuming that none contain a newline, although other whitespace is | ||
21 | # preserved. | ||
22 | LF=' | ||
23 | ' | ||
24 | test_argv= | ||
25 | |||
26 | while test $# != 0 | ||
27 | do | ||
28 | case "$1" in | ||
29 | --va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind) | ||
30 | cgit_valgrind=t | ||
31 | test_argv="$test_argv${LF}--verbose" | ||
32 | ;; | ||
33 | *) | ||
34 | test_argv="$test_argv$LF$1" | ||
35 | ;; | ||
36 | esac | ||
37 | shift | ||
38 | done | ||
39 | |||
40 | OLDIFS=$IFS | ||
41 | IFS=$LF | ||
42 | set -- $test_argv | ||
43 | IFS=$OLDIFS | ||
44 | |||
18 | : ${TEST_DIRECTORY=$(pwd)/../git/t} | 45 | : ${TEST_DIRECTORY=$(pwd)/../git/t} |
19 | : ${TEST_OUTPUT_DIRECTORY=$(pwd)} | 46 | : ${TEST_OUTPUT_DIRECTORY=$(pwd)} |
20 | TEST_NO_CREATE_REPO=YesPlease | 47 | TEST_NO_CREATE_REPO=YesPlease |
21 | . "$TEST_DIRECTORY"/test-lib.sh | 48 | . "$TEST_DIRECTORY"/test-lib.sh |
22 | 49 | ||
23 | # Prepend the directory containing cgit to PATH. | 50 | # Prepend the directory containing cgit to PATH. |
24 | PATH="$(pwd)/../..:$PATH" | 51 | if test -n "$cgit_valgrind" |
52 | then | ||
53 | GIT_VALGRIND="$TEST_DIRECTORY/valgrind" | ||
54 | CGIT_VALGRIND=$(cd ../valgrind && pwd) | ||
55 | PATH="$CGIT_VALGRIND/bin:$PATH" | ||
56 | export GIT_VALGRIND CGIT_VALGRIND | ||
57 | else | ||
58 | PATH="$(pwd)/../..:$PATH" | ||
59 | fi | ||
25 | 60 | ||
26 | mkrepo() { | 61 | mkrepo() { |
27 | name=$1 | 62 | 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 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Note that we currently use Git's suppression file and there are variables | ||
4 | # $GIT_VALGRIND and $CGIT_VALGRIND which point to different places. | ||
5 | exec valgrind -q --error-exitcode=126 \ | ||
6 | --suppressions="$GIT_VALGRIND/default.supp" \ | ||
7 | --gen-suppressions=all \ | ||
8 | --leak-check=no \ | ||
9 | --track-origins=yes \ | ||
10 | --log-fd=4 \ | ||
11 | --input-fd=4 \ | ||
12 | "$CGIT_VALGRIND/../../cgit" "$@" | ||