Skip to content

Commit

Permalink
Merge branch 'ep/malloc-check-perturb'
Browse files Browse the repository at this point in the history
Run our test scripts with MALLOC_CHECK_ and MALLOC_PERTURB_, the
built-in memory access checking facility GNU libc has.

* ep/malloc-check-perturb:
  MALLOC_CHECK: various clean-ups
  Add MALLOC_CHECK_ and MALLOC_PERTURB_ libc env to the test suite for detecting heap corruption
  • Loading branch information
Junio C Hamano committed Sep 25, 2012
2 parents c4eed86 + 1b3185f commit 0ec6aa5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions t/perf/perf-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ else
fi

TEST_NO_CREATE_REPO=t
TEST_NO_MALLOC_=t

. ../test-lib.sh

Expand Down
23 changes: 23 additions & 0 deletions t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,27 @@ export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
export EDITOR

# Add libc MALLOC and MALLOC_PERTURB test
# only if we are not executing the test with valgrind
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
unset CDPATH
Expand Down Expand Up @@ -302,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
Expand Down

0 comments on commit 0ec6aa5

Please sign in to comment.