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>
This commit is contained in:
Junio C Hamano 2012-09-14 20:38:24 -07:00
Родитель a731fa916e
Коммит 1b3185fc2b
2 изменённых файлов: 21 добавлений и 6 удалений

Просмотреть файл

@ -42,6 +42,7 @@ else
fi fi
TEST_NO_CREATE_REPO=t TEST_NO_CREATE_REPO=t
TEST_NO_MALLOC_=t
. ../test-lib.sh . ../test-lib.sh

Просмотреть файл

@ -95,12 +95,24 @@ export EDITOR
# Add libc MALLOC and MALLOC_PERTURB test # Add libc MALLOC and MALLOC_PERTURB test
# only if we are not executing the test with valgrind # only if we are not executing the test with valgrind
expr "$GIT_TEST_OPTS" : ".*\(--valgrind\)" >/dev/null || { if expr " $GIT_TEST_OPTS " : ".* --valgrind " >/dev/null ||
MALLOC_CHECK_=3 test -n "TEST_NO_MALLOC_"
export MALLOC_CHECK_ then
MALLOC_PERTURB_="$( expr \( $$ % 255 \) + 1)" setup_malloc_check () {
export MALLOC_PERTURB_ : 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 # Protect ourselves from common misconfiguration to export
# CDPATH into the environment # CDPATH into the environment
@ -311,7 +323,9 @@ test_run_ () {
if test -z "$immediate" || test $eval_ret = 0 || test -n "$expecting_failure" if test -z "$immediate" || test $eval_ret = 0 || test -n "$expecting_failure"
then then
setup_malloc_check
test_eval_ "$test_cleanup" test_eval_ "$test_cleanup"
teardown_malloc_check
fi fi
if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE" if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"
then then