Merge branch 'ep/test-malloc-check-with-glibc-2.34'

The method to trigger malloc check used in our tests no longer work
with newer versions of glibc.

* ep/test-malloc-check-with-glibc-2.34:
  test-lib: declare local variables as local
  test-lib.sh: Use GLIBC_TUNABLES instead of MALLOC_CHECK_ on glibc >= 2.34
This commit is contained in:
Junio C Hamano 2022-03-21 15:14:23 -07:00
commit b6763af74b

View File

@ -548,11 +548,29 @@ then
}
else
setup_malloc_check () {
local g
local t
MALLOC_CHECK_=3 MALLOC_PERTURB_=165
export MALLOC_CHECK_ MALLOC_PERTURB_
if _GLIBC_VERSION=$(getconf GNU_LIBC_VERSION 2>/dev/null) &&
_GLIBC_VERSION=${_GLIBC_VERSION#"glibc "} &&
expr 2.34 \<= "$_GLIBC_VERSION" >/dev/null
then
g=
LD_PRELOAD="libc_malloc_debug.so.0"
for t in \
glibc.malloc.check=1 \
glibc.malloc.perturb=165
do
g="${g#:}:$t"
done
GLIBC_TUNABLES=$g
export LD_PRELOAD GLIBC_TUNABLES
fi
}
teardown_malloc_check () {
unset MALLOC_CHECK_ MALLOC_PERTURB_
unset LD_PRELOAD GLIBC_TUNABLES
}
fi