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>
Junio C Hamano committed
Sep 14, 2012 at 20:38 UTC
1b3185fc2be3cc92a834fcfcb7110d1072184700
2 files changed
+21
-6
t/perf/perf-lib.sh
+1
@@ -42,6 +42,7 @@ else
42
fi
43
44
TEST_NO_CREATE_REPO=t
45
+TEST_NO_MALLOC_=t
46
47
. ../test-lib.sh
48
t/test-lib.sh
+20
-6
@@ -95,12 +95,24 @@ export EDITOR
95
96
# Add libc MALLOC and MALLOC_PERTURB test
97
# only if we are not executing the test with valgrind
98
-expr "$GIT_TEST_OPTS" : ".*\(--valgrind\)" >/dev/null || {
99
- MALLOC_CHECK_=3
100
- export MALLOC_CHECK_
101
- MALLOC_PERTURB_="$( expr \( $$ % 255 \) + 1)"
102
- export MALLOC_PERTURB_
103
-}
98
+if expr " $GIT_TEST_OPTS " : ".* --valgrind " >/dev/null ||
99
+ test -n "TEST_NO_MALLOC_"
100
+then
101
+ setup_malloc_check () {
102
+ : nothing
103
+ }
104
+ teardown_malloc_check () {
105
+ : nothing
106
+ }
107
+else
108
+ setup_malloc_check () {
109
+ MALLOC_CHECK_=3 MALLOC_PERTURB_=165
110
+ export MALLOC_CHECK_ MALLOC_PERTURB_
111
+ }
112
+ teardown_malloc_check () {
113
+ unset MALLOC_CHECK_ MALLOC_PERTURB_
114
+ }
115
+fi
116
117
# Protect ourselves from common misconfiguration to export
118
# CDPATH into the environment
@@ -311,7 +323,9 @@ test_run_ () {
323
324
if test -z "$immediate" || test $eval_ret = 0 || test -n "$expecting_failure"
325
then
326
+ setup_malloc_check
327
test_eval_ "$test_cleanup"
328
+ teardown_malloc_check
329
fi
330
if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"
331
then