]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tests: cache glibc version check
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Thu, 4 Aug 2022 13:38:25 +0000 (13:38 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 4 Aug 2022 18:09:18 +0000 (11:09 -0700)
131b94a10a ("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 <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh

index 8cabb4d10f9aaf9e500cd27b9be91fe9719d62a9..120f11812c364ae6467e61cf8eac1f92cd73a385 100644 (file)
@@ -557,14 +557,19 @@ then
                : nothing
        }
 else
+       _USE_GLIBC_TUNABLES=
+       if _GLIBC_VERSION=$(getconf GNU_LIBC_VERSION 2>/dev/null) &&
+          _GLIBC_VERSION=${_GLIBC_VERSION#"glibc "} &&
+          expr 2.34 \<= "$_GLIBC_VERSION" >/dev/null
+       then
+               _USE_GLIBC_TUNABLES=YesPlease
+       fi
        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
+               if test -n "$_USE_GLIBC_TUNABLES"
                then
                        g=
                        LD_PRELOAD="libc_malloc_debug.so.0"