From 44c1d728b11fb970d040313d519a6372ac77652c Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 08:34:51 -1000 Subject: Keep cgit under Valgrind whichever way it is asked The library runs a script again for --tee, --verbose-log and --stress with the arguments setup.sh left it, and --valgrind was no longer among them, so -V --valgrind ran cgit bare. --valgrind= reached the library instead, which then wrapped every Git command and left cgit alone. --valgrind-only is refused, as it would need the library's own per-test switching. --- tests/setup.sh | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'tests/setup.sh') 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 -- cgit 2.12.1