Skip to content

Commit 1b3185f

Browse files
committed
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 <[email protected]>
1 parent a731fa9 commit 1b3185f

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

t/perf/perf-lib.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ else
4242
fi
4343

4444
TEST_NO_CREATE_REPO=t
45+
TEST_NO_MALLOC_=t
4546

4647
. ../test-lib.sh
4748

t/test-lib.sh

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,24 @@ export EDITOR
9595

9696
# Add libc MALLOC and MALLOC_PERTURB test
9797
# 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
104116

105117
# Protect ourselves from common misconfiguration to export
106118
# CDPATH into the environment
@@ -311,7 +323,9 @@ test_run_ () {
311323

312324
if test -z "$immediate" || test $eval_ret = 0 || test -n "$expecting_failure"
313325
then
326+
setup_malloc_check
314327
test_eval_ "$test_cleanup"
328+
teardown_malloc_check
315329
fi
316330
if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"
317331
then

0 commit comments

Comments
 (0)