Diff options
| -rw-r--r-- | README.txt | 6 | |
| -rw-r--r-- | tests/setup.sh | 30 | |
| -rwxr-xr-x | tests/valgrind/bin/cgit | 21 |
3 files changed, 44 insertions, 13 deletions
@@ -334,8 +334,10 @@ The scripts take the options of Git's test library, such as -v to show what each test does and prints, -i to stop at the first failure and --run to pick tests by number, and make test passes them on through CGIT_TEST_OPTS. A failing test shows only its name and its commands, so run its script again with -v to -see why it failed. The trash directories need a local filesystem, as the cache -tests rely on flock locks, which NFS can only emulate. +see why it failed. --valgrind runs cgit, and only cgit, under Valgrind's +memcheck, and --valgrind=<tool> under another tool. The trash directories need +a local filesystem, as the cache tests rely on flock locks, which NFS can only +emulate. make test builds with the flags on its own command line, so after tools/build-development.sh a plain make test would rebuild and test an ordinary diff --git a/tests/setup.sh b/tests/setup.sh index c61fa85..26a3f67 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -15,13 +15,21 @@ test_argv="${LF}--root=trash" # The Git test library would run every Git command under Valgrind if it saw # --valgrind, and only cgit is worth watching, so the option is taken out -# here and acted on further down. +# here and acted on further down. The tool chosen is exported, as the library +# runs the script again without it for --tee, --verbose-log and --stress. +# Valgrind reports on the verbose output, which it therefore turns on. while test $# != 0 do case "$1" in --va|--val|--valg|--valgr|--valgri|--valgrin|--valgrind) - cgit_valgrind=t - test_argv="$test_argv${LF}--verbose" + CGIT_TEST_VALGRIND=memcheck + ;; + --valgrind=*) + CGIT_TEST_VALGRIND=${1#--*=} + ;; + --valgrind-only=*) + echo "error: --valgrind-only is not supported, use --valgrind with --run" >&2 + exit 1 ;; *) test_argv="$test_argv$LF$1" @@ -29,6 +37,11 @@ do esac shift done +if test -n "$CGIT_TEST_VALGRIND" +then + test_argv="$test_argv${LF}--verbose" + export CGIT_TEST_VALGRIND +fi # Globbing is off while the arguments are split apart again, so one that looks # like a pattern reaches the library as it was given. @@ -103,13 +116,16 @@ test_atexit cgit_check_sanitizer_logs # The library has moved into the trash directory by now, so paths outside it # are anchored to TEST_OUTPUT_DIRECTORY. The tests run cgit by name, so the # binary just built has to come ahead of any copy already installed. Under -# Valgrind the wrappers take that place instead. -if test -n "$cgit_valgrind" +# Valgrind the wrappers take that place instead, and find valgrind by the path +# looked up here, as a few tests run cgit with no PATH at all. +if test -n "$CGIT_TEST_VALGRIND" then GIT_VALGRIND="$TEST_DIRECTORY/valgrind" CGIT_VALGRIND=$(cd "$TEST_OUTPUT_DIRECTORY/valgrind" && pwd) + CGIT_VALGRIND_PROGRAM=$(command -v valgrind) || + BAIL_OUT "--valgrind needs valgrind on the PATH" PATH="$CGIT_VALGRIND/bin:$PATH" - export GIT_VALGRIND CGIT_VALGRIND + export GIT_VALGRIND CGIT_VALGRIND CGIT_VALGRIND_PROGRAM else PATH="$TEST_OUTPUT_DIRECTORY/../build:$PATH" fi @@ -132,7 +148,7 @@ case "$cgit_version" in ;; esac cgit_flags="$TEST_OUTPUT_DIRECTORY/../build/CGIT-CFLAGS" -if test -z "$cgit_valgrind" && test -f "$cgit_flags" +if test -z "$CGIT_TEST_VALGRIND" && test -f "$cgit_flags" then if grep -e "-DNO_LUA" "$cgit_flags" >/dev/null then diff --git a/tests/valgrind/bin/cgit b/tests/valgrind/bin/cgit index e35e220..e5666b5 100755 --- a/tests/valgrind/bin/cgit +++ b/tests/valgrind/bin/cgit @@ -4,12 +4,25 @@ # when setup.sh puts this directory ahead of the build on PATH. Git's own # suppression file is reused rather than kept in a copy here, so GIT_VALGRIND # points into the bundled Git tree while CGIT_VALGRIND points back at this -# wrapper's home. -exec valgrind -q --error-exitcode=126 \ +# wrapper's home. The tool comes from --valgrind=<tool> and its options follow +# Git's own wrapper, with any in GIT_VALGRIND_OPTIONS added after them. +case "$CGIT_TEST_VALGRIND" in +memcheck) + tool_options="--leak-check=no --track-origins=yes" + ;; +memcheck-fast) + tool_options="--leak-check=no" + ;; +*) + tool_options="--tool=$CGIT_TEST_VALGRIND" + ;; +esac + +exec "$CGIT_VALGRIND_PROGRAM" -q --error-exitcode=126 \ --suppressions="$GIT_VALGRIND/default.supp" \ --gen-suppressions=all \ - --leak-check=no \ - --track-origins=yes \ + $tool_options \ --log-fd=4 \ --input-fd=4 \ + $GIT_VALGRIND_OPTIONS \ "$CGIT_VALGRIND/../../build/cgit" "$@" |
