valgrind: support test helpers

Tests run with --valgrind call git commands through a wrapper script that invokes valgrind on them. This script (valgrind.sh) is in turn invoked through symlinks created for each command in t/valgrind/bin/. Since e6e7530d (test helpers: move test-* to t/helper/ subdirectory) these symlinks have been broken for test helpers -- they point to the old locations in the root of the build directory. Fix that by teaching the code for creating the links about the new location of the binaries, and do the same in the wrapper script to allow it to find its payload. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Oct 28, 2016 at 00:14 UTC 28fab7b23d0f9f15745c99baf25ec49e38594aa5
2 files changed +18 -3
t/test-lib.sh
+8 -1
@@ -766,7 +766,14 @@ then
766 return;
767
768 base=$(basename "$1")
769 - symlink_target=$GIT_BUILD_DIR/$base
769 + case "$base" in
770 + test-*)
771 + symlink_target="$GIT_BUILD_DIR/t/helper/$base"
772 + ;;
773 + *)
774 + symlink_target="$GIT_BUILD_DIR/$base"
775 + ;;
776 + esac
777 # do not override scripts
778 if test -x "$symlink_target" &&
779 test ! -d "$symlink_target" &&
t/valgrind/valgrind.sh
+10 -2
@@ -1,11 +1,19 @@
1 #!/bin/sh
2
3 base=$(basename "$0")
4 +case "$base" in
5 +test-*)
6 + program="$GIT_VALGRIND/../../t/helper/$base"
7 + ;;
8 +*)
9 + program="$GIT_VALGRIND/../../$base"
10 + ;;
11 +esac
12
13 TOOL_OPTIONS='--leak-check=no'
14
15 test -z "$GIT_VALGRIND_ENABLED" &&
8 -exec "$GIT_VALGRIND"/../../"$base" "$@"
16 +exec "$program" "$@"
17
18 case "$GIT_VALGRIND_MODE" in
19 memcheck-fast)
@@ -29,4 +37,4 @@ exec valgrind -q --error-exitcode=126 \
37 --log-fd=4 \
38 --input-fd=4 \
39 $GIT_VALGRIND_OPTIONS \
32 - "$GIT_VALGRIND"/../../"$base" "$@"
40 + "$program" "$@"