Skip to content

Commit

Permalink
valgrind: support test helpers
Browse files Browse the repository at this point in the history
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 e6e7530 (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>
  • Loading branch information
rscharfe authored and gitster committed Oct 28, 2016
1 parent 503e224 commit 28fab7b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
9 changes: 8 additions & 1 deletion t/test-lib.sh
Expand Up @@ -766,7 +766,14 @@ then
return;

base=$(basename "$1")
symlink_target=$GIT_BUILD_DIR/$base
case "$base" in
test-*)
symlink_target="$GIT_BUILD_DIR/t/helper/$base"
;;
*)
symlink_target="$GIT_BUILD_DIR/$base"
;;
esac
# do not override scripts
if test -x "$symlink_target" &&
test ! -d "$symlink_target" &&
Expand Down
12 changes: 10 additions & 2 deletions t/valgrind/valgrind.sh
@@ -1,11 +1,19 @@
#!/bin/sh

base=$(basename "$0")
case "$base" in
test-*)
program="$GIT_VALGRIND/../../t/helper/$base"
;;
*)
program="$GIT_VALGRIND/../../$base"
;;
esac

TOOL_OPTIONS='--leak-check=no'

test -z "$GIT_VALGRIND_ENABLED" &&
exec "$GIT_VALGRIND"/../../"$base" "$@"
exec "$program" "$@"

case "$GIT_VALGRIND_MODE" in
memcheck-fast)
Expand All @@ -29,4 +37,4 @@ exec valgrind -q --error-exitcode=126 \
--log-fd=4 \
--input-fd=4 \
$GIT_VALGRIND_OPTIONS \
"$GIT_VALGRIND"/../../"$base" "$@"
"$program" "$@"

0 comments on commit 28fab7b

Please sign in to comment.