]> git.ipfire.org Git - thirdparty/git.git/commitdiff
MALLOC_CHECK: various clean-ups
authorJunio C Hamano <gitster@pobox.com>
Sat, 15 Sep 2012 03:38:24 +0000 (20:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Sep 2012 05:00:27 +0000 (22:00 -0700)
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>
t/perf/perf-lib.sh
t/test-lib.sh

index a1361e530c60609a52948dd0fd35642d57f84486..1d0bb9d0173af5908b46285dbd574642fb20a22e 100644 (file)
@@ -42,6 +42,7 @@ else
 fi
 
 TEST_NO_CREATE_REPO=t
+TEST_NO_MALLOC_=t
 
 . ../test-lib.sh
 
index b0c0c84714d711a1285cc9f06ec73dc4c4cfc9a9..aad46066adf0021b721bb3a2e235e2b012f13422 100644 (file)
@@ -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