git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] tests: cache glibc version check

From
PGPhillip Wood via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 4, 2022, 13:38 UTC
Message-ID
<pull.1311.git.1659620305757.gitgitgadget@gmail.com>
From: Phillip Wood <phillip.wood@dunelm.org.uk>

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>
---
    tests: cache glibc version check
    
    A recent discussion on the list[1] reminded me that this patch was
    waiting to be sent.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1311%2Fphillipwood%2Fwip%2Ftest-cache-glibc-tunables-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1311/phillipwood/wip/test-cache-glibc-tunables-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1311
 t/test-lib.sh | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 7726d1da88a..ad81c78fce7 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -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"

base-commit: 23b219f8e3f2adfb0441e135f0a880e6124f766c
-- 
gitgitgadget
Next: Phillip Wood
Message 1 of 6 in “tests: cache glibc version check”
  1. tests: cache glibc version checkPhillip Wood via GitGitGadget, Aug 4, 2022
  2. Phillip WoodAug 4, 2022
  3. Junio C HamanoAug 4, 2022
  4. Phillip WoodAug 4, 2022
  5. Junio C HamanoAug 4, 2022
  6. Junio C HamanoAug 4, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.