all repos — cgit @ 1b1974c45e5e23e5527aa43c4d9ece423a13dfdc

a hyperfast web frontend for git written in c

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>
John Keeping john@keeping.me.uk
Mon, 08 Apr 2013 20:12:38 +0100
commit

1b1974c45e5e23e5527aa43c4d9ece423a13dfdc

parent

382ecf152e1bd9546f6c84ace71c62ca07f6648b

2 files changed, 48 insertions(+), 1 deletions(-)

jump to
M tests/setup.shtests/setup.sh

@@ -15,13 +15,48 @@ # prepare_tests "html validation"

# 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_OUTPUT_DIRECTORY=$(pwd)} 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
A 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" "$@"