[INTERDIFF of PATCH 1/2 v2] Add valgrind support in test scripts
t/README | 6 +++++-
t/test-lib.sh | 32 +++++++++++++++++++++-----------
t/valgrind/.gitignore | 3 +--
t/valgrind/valgrind.sh | 4 ++--
4 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/t/README b/t/README
index 8f12d48..0cee429 100644
--- a/t/README
+++ b/t/README
@@ -39,7 +39,8 @@ this:
* passed all 3 test(s)
You can pass --verbose (or -v), --debug (or -d), and --immediate
-(or -i) command line argument to the test.
+(or -i) command line argument to the test, or by setting GIT_TEST_OPTS
+appropriately before running "make".
--verbose::
This makes the test more verbose. Specifically, the
@@ -58,6 +59,9 @@ You can pass --verbose (or -v), --debug (or -d), and --immediate
This causes additional long-running tests to be run (where
available), for more exhaustive testing.
+--valgrind::
+ Execute all Git binaries with valgrind and stop on errors (the
+ exit code will be 126).
Skipping Tests
--------------
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 6bd893d..f031905 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -488,27 +488,37 @@ then
GIT_EXEC_PATH=$TEST_DIRECTORY/..
else
# override all git executables in PATH and TEST_DIRECTORY/..
- GIT_VALGRIND=$TEST_DIRECTORY/valgrind
+ GIT_VALGRIND=$TEST_DIRECTORY/valgrind/bin
mkdir -p "$GIT_VALGRIND"
OLDIFS=$IFS
IFS=:
- for path in $PATH:$TEST_DIRECTORY/..
+ for path in $PATH $TEST_DIRECTORY/..
do
- ls "$TEST_DIRECTORY"/../git "$path"/git-* 2> /dev/null |
+ ls "$path"/git "$path"/git-* 2> /dev/null |
while read file
do
# handle only executables
- test -x "$file" || continue
+ test -x "$file" && test ! -d "$file" || continue
base=$(basename "$file")
- test ! -h "$GIT_VALGRIND"/"$base" || continue
-
- if test "#!" = "$(head -c 2 < "$file")"
+ symlink_target=$TEST_DIRECTORY/../$base
+ # do not override scripts
+ if test -x "$symlink_target" &&
+ test "#!" != "$(head -c 2 < "$symlink_target")"
+ then
+ symlink_target=../valgrind.sh
+ fi
+ case "$base" in
+ *.sh|*.perl)
+ symlink_target=../unprocessed-script
+ esac
+ # create the link, or replace it if it is out of date
+ if test ! -h "$GIT_VALGRIND"/"$base" ||
+ test "$symlink_target" != \
+ "$(readlink "$GIT_VALGRIND"/"$base")"
then
- # do not override scripts
- ln -s ../../"$base" "$GIT_VALGRIND"/"$base"
- else
- ln -s valgrind.sh "$GIT_VALGRIND"/"$base"
+ rm -f "$GIT_VALGRIND"/"$base" || exit
+ ln -s "$symlink_target" "$GIT_VALGRIND"/"$base"
fi
done
done
diff --git a/t/valgrind/.gitignore b/t/valgrind/.gitignore
index d781a63..ae3c172 100644
--- a/t/valgrind/.gitignore
+++ b/t/valgrind/.gitignore
@@ -1,2 +1 @@
-/git
-/git-*
+/bin/
diff --git a/t/valgrind/valgrind.sh b/t/valgrind/valgrind.sh
index 24f3a4e..2c4b54b 100755
--- a/t/valgrind/valgrind.sh
+++ b/t/valgrind/valgrind.sh
@@ -4,9 +4,9 @@ base=$(basename "$0")
exec valgrind -q --error-exitcode=126 \
--leak-check=no \
- --suppressions="$GIT_VALGRIND/default.supp" \
+ --suppressions="$GIT_VALGRIND/../default.supp" \
--gen-suppressions=all \
--log-fd=4 \
--input-fd=4 \
$GIT_VALGRIND_OPTIONS \
- "$GIT_VALGRIND"/../../"$base" "$@"
+ "$GIT_VALGRIND"/../../../"$base" "$@"