diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-09-14 20:38:24 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-09-17 22:00:27 -0700 |
commit | 1b3185fc2be3cc92a834fcfcb7110d1072184700 (patch) | |
tree | 98a90bc1a144e41ce727b9270a7e19de0acd0887 /t | |
parent | a731fa916e5ce000eeb23f3c858c9218c78633d6 (diff) | |
download | git-1b3185fc2be3cc92a834fcfcb7110d1072184700.tar.gz git-1b3185fc2be3cc92a834fcfcb7110d1072184700.tar.xz |
MALLOC_CHECK: various clean-ups
The most important in this change is to avoid affecting anything
when test-lib is used from perf-lib. It also limits the effect of
the MALLOC_CHECK only to what is run inside the actual test, and
uses a fixed MALLOC_PERTURB_ in order to avoid hurting repeatability
of the tests.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rw-r--r-- | t/perf/perf-lib.sh | 1 | ||||
-rw-r--r-- | t/test-lib.sh | 26 |
2 files changed, 21 insertions, 6 deletions
diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh index a1361e530..1d0bb9d01 100644 --- a/t/perf/perf-lib.sh +++ b/t/perf/perf-lib.sh @@ -42,6 +42,7 @@ else fi TEST_NO_CREATE_REPO=t +TEST_NO_MALLOC_=t . ../test-lib.sh diff --git a/t/test-lib.sh b/t/test-lib.sh index b0c0c8471..aad46066a 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -95,12 +95,24 @@ export EDITOR # Add libc MALLOC and MALLOC_PERTURB test # only if we are not executing the test with valgrind -expr "$GIT_TEST_OPTS" : ".*\(--valgrind\)" >/dev/null || { - MALLOC_CHECK_=3 - export MALLOC_CHECK_ - MALLOC_PERTURB_="$( expr \( $$ % 255 \) + 1)" - export MALLOC_PERTURB_ -} +if expr " $GIT_TEST_OPTS " : ".* --valgrind " >/dev/null || + test -n "TEST_NO_MALLOC_" +then + setup_malloc_check () { + : nothing + } + teardown_malloc_check () { + : nothing + } +else + setup_malloc_check () { + MALLOC_CHECK_=3 MALLOC_PERTURB_=165 + export MALLOC_CHECK_ MALLOC_PERTURB_ + } + teardown_malloc_check () { + unset MALLOC_CHECK_ MALLOC_PERTURB_ + } +fi # Protect ourselves from common misconfiguration to export # CDPATH into the environment @@ -311,7 +323,9 @@ test_run_ () { if test -z "$immediate" || test $eval_ret = 0 || test -n "$expecting_failure" then + setup_malloc_check test_eval_ "$test_cleanup" + teardown_malloc_check fi if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE" then |