Skip to content

Commit a6a58f7

Browse files
phillipwoodgitster
authored andcommitted
tests: cache glibc version check
131b94a ("test-lib.sh: Use GLIBC_TUNABLES instead of MALLOC_CHECK_ on glibc >= 2.34", 2022-03-04) introduced a check for the version of glibc that is in use. This check is performed as part of setup_malloc_check() which is called at least once for each test. As the test involves forking `getconf` and `expr` cache the result and use that within setup_malloc_check() to avoid forking these extra processes for each test. Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 00d1260 commit a6a58f7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

t/test-lib.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,14 +557,19 @@ then
557557
: nothing
558558
}
559559
else
560+
_USE_GLIBC_TUNABLES=
561+
if _GLIBC_VERSION=$(getconf GNU_LIBC_VERSION 2>/dev/null) &&
562+
_GLIBC_VERSION=${_GLIBC_VERSION#"glibc "} &&
563+
expr 2.34 \<= "$_GLIBC_VERSION" >/dev/null
564+
then
565+
_USE_GLIBC_TUNABLES=YesPlease
566+
fi
560567
setup_malloc_check () {
561568
local g
562569
local t
563570
MALLOC_CHECK_=3 MALLOC_PERTURB_=165
564571
export MALLOC_CHECK_ MALLOC_PERTURB_
565-
if _GLIBC_VERSION=$(getconf GNU_LIBC_VERSION 2>/dev/null) &&
566-
_GLIBC_VERSION=${_GLIBC_VERSION#"glibc "} &&
567-
expr 2.34 \<= "$_GLIBC_VERSION" >/dev/null
572+
if test -n "$_USE_GLIBC_TUNABLES"
568573
then
569574
g=
570575
LD_PRELOAD="libc_malloc_debug.so.0"

0 commit comments

Comments
 (0)