summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid A. Greene <greened@obbligato.org>2012-03-04 17:23:57 -0600
committerJunio C Hamano <gitster@pobox.com>2012-03-04 22:37:31 -0800
commitee27c5208ae37c169fd706f47cba248098153bce (patch)
tree98a7a7364e759fbad2f8898d3c3cef878b2c47ba
parent457fb50c8dc888d299557e8b628ee839b4d4f973 (diff)
downloadgit-dg/test-from-elsewhere.tar.gz
Support out-of-tree Valgrind testsdg/test-from-elsewhere
Allow tests that do not live in the top-level t/ directory to run under valgrind. This requires exporting a couple more variables to indicate where the git tools were built and where the valgrind support files live. Prior to this chage the valgrind support files were hard-coded to be in a sibling directory to where the valgrind tests are run. Also prior to this change the base git build was hard-coded to be exactly two directories up from where the valgrind tests are run. Signed-off-by: David A. Greene <greened@obbligato.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--t/test-lib.sh22
-rwxr-xr-xt/valgrind/valgrind.sh4
2 files changed, 22 insertions, 4 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh
index d825148fe5..0901bfaf34 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -55,6 +55,7 @@ unset $(perl -e '
.*_TEST
PROVE
VALGRIND
+ VALGRIND_TOOLS
PERF_AGGREGATING_LATER
BUILD_DIR
));
@@ -411,6 +412,20 @@ then
GIT_BUILD_DIR="$TEST_DIRECTORY"/..
fi
+# GIT_VALGRIND_TOOLS is the location of tools like valgrind.sh.
+if test -z "$GIT_VALGRIND_TOOLS"
+then
+ # We allow tests to override this, in case they want to run tests
+ # outside of t/.
+
+ # For in-tree test scripts, this is in TEST_DIRECTORY/valgrind
+ # (t/valgrind), but a test script that lives outside t/ can
+ # set this variable to point at the right place so that it can
+ # find t/valgrind directory that house test helpers like
+ # valgrind.sh.
+ GIT_VALGRIND_TOOLS="$TEST_DIRECTORY"/valgrind
+fi
+
if test -n "$valgrind"
then
make_symlink () {
@@ -448,11 +463,11 @@ then
test ! -d "$symlink_target" &&
test "#!" != "$(head -c 2 < "$symlink_target")"
then
- symlink_target=../valgrind.sh
+ symlink_target=${GIT_VALGRIND_TOOLS}/valgrind.sh
fi
case "$base" in
*.sh|*.perl)
- symlink_target=../unprocessed-script
+ symlink_target=${GIT_VALGRIND_TOOLS}/unprocessed-script
esac
# create the link, or replace it if it is out of date
make_symlink "$symlink_target" "$GIT_VALGRIND/bin/$base" || exit
@@ -480,7 +495,10 @@ then
IFS=$OLDIFS
PATH=$GIT_VALGRIND/bin:$PATH
GIT_EXEC_PATH=$GIT_VALGRIND/bin
+ # Make these available in valgrind.sh
+ export GIT_BUILD_DIR
export GIT_VALGRIND
+ export GIT_VALGRIND_TOOLS
elif test -n "$GIT_TEST_INSTALLED" ; then
GIT_EXEC_PATH=$($GIT_TEST_INSTALLED/git --exec-path) ||
error "Cannot run git from $GIT_TEST_INSTALLED."
diff --git a/t/valgrind/valgrind.sh b/t/valgrind/valgrind.sh
index 582b4dca94..d638d10fda 100755
--- a/t/valgrind/valgrind.sh
+++ b/t/valgrind/valgrind.sh
@@ -13,10 +13,10 @@ TRACK_ORIGINS=--track-origins=yes
exec valgrind -q --error-exitcode=126 \
--leak-check=no \
- --suppressions="$GIT_VALGRIND/default.supp" \
+ --suppressions="$GIT_VALGRIND_TOOLS/default.supp" \
--gen-suppressions=all \
$TRACK_ORIGINS \
--log-fd=4 \
--input-fd=4 \
$GIT_VALGRIND_OPTIONS \
- "$GIT_VALGRIND"/../../"$base" "$@"
+ "$GIT_BUILD_DIR"/"$base" "$@"