[PATCH v5] strace-tst-thp.sh: Allow unsupported THP tests

"H.J. Lu" <[email protected]>
Newsgroups gmane.comp.lib.glibc.alpha
Message-ID <CAMe9rOp3MzSaKgxxvfuGchuSkh3yho1Zavh4YB4_vrY=-rzovA@mail.gmail.com>
Change strace-tst-thp.sh to check the command exit status and use $(BASH)
to run it so that unsupported THP tests exit with status 77.


-- 
H.J.
v5-0001-strace-tst-thp.sh-Allow-unsupported-THP-tests.patch (text/x-patch, 5.8 KB)
From e7dadf9e3b28b54a07ec3cd435ba4f1173e1d1fa Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <[email protected]>
Date: Sat, 4 Jul 2026 11:06:21 +0800
Subject: [PATCH v5] strace-tst-thp.sh: Allow unsupported THP tests

Change strace-tst-thp.sh to check the command exit status and use $(BASH)
to run it so that unsupported THP tests exit with status 77.

Signed-off-by: H.J. Lu <[email protected]>
---
 sysdeps/unix/sysv/linux/Makefile          | 18 +++++++++---------
 sysdeps/unix/sysv/linux/strace-tst-thp.sh | 22 ++++++++++------------
 2 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 14a56d5cc3..563a85aaa0 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -842,7 +842,7 @@ endif
 $(objpfx)strace-tst-thp-1-enabled.out: \
   $(..)sysdeps/unix/sysv/linux/strace-tst-thp.sh $(objpfx)ld.so \
   $(objpfx)tst-thp-1
-	$(SHELL) $< '$(strace-test-via-rtld-prefix)' \
+	$(BASH) $< '$(strace-test-via-rtld-prefix)' \
 		'$(test-wrapper-env)' \
 		'$(run-program-env) GLIBC_TUNABLES=glibc.elf.thp=1' \
 		$(objpfx)tst-thp-1 > $@; \
@@ -851,7 +851,7 @@ $(objpfx)strace-tst-thp-1-enabled.out: \
 $(objpfx)strace-tst-thp-1-disabled.out: \
   $(..)sysdeps/unix/sysv/linux/strace-tst-thp.sh $(objpfx)ld.so \
   $(objpfx)tst-thp-1
-	$(SHELL) $< '$(strace-test-via-rtld-prefix)' \
+	$(BASH) $< '$(strace-test-via-rtld-prefix)' \
 		'$(test-wrapper-env)' \
 		'$(run-program-env) GLIBC_TUNABLES=glibc.elf.thp=0' \
 		$(objpfx)tst-thp-1 > $@; \
@@ -860,7 +860,7 @@ $(objpfx)strace-tst-thp-1-disabled.out: \
 $(objpfx)strace-tst-thp-1-pde-enabled.out: \
   $(..)sysdeps/unix/sysv/linux/strace-tst-thp.sh $(objpfx)ld.so \
   $(objpfx)tst-thp-1-pde
-	$(SHELL) $< '$(strace-test-via-rtld-prefix)' \
+	$(BASH) $< '$(strace-test-via-rtld-prefix)' \
 		'$(test-wrapper-env)' \
 		'$(run-program-env) GLIBC_TUNABLES=glibc.elf.thp=1' \
 		$(objpfx)tst-thp-1-pde > $@; \
@@ -869,7 +869,7 @@ $(objpfx)strace-tst-thp-1-pde-enabled.out: \
 $(objpfx)strace-tst-thp-1-pde-disabled.out: \
   $(..)sysdeps/unix/sysv/linux/strace-tst-thp.sh $(objpfx)ld.so \
   $(objpfx)tst-thp-1-pde
-	$(SHELL) $< '$(strace-test-via-rtld-prefix)' \
+	$(BASH) $< '$(strace-test-via-rtld-prefix)' \
 		'$(test-wrapper-env)' \
 		'$(run-program-env) GLIBC_TUNABLES=glibc.elf.thp=0' \
 		$(objpfx)tst-thp-1-pde > $@; \
@@ -878,7 +878,7 @@ $(objpfx)strace-tst-thp-1-pde-disabled.out: \
 $(objpfx)strace-tst-thp-1-static-enabled.out: \
   $(..)sysdeps/unix/sysv/linux/strace-tst-thp.sh \
   $(objpfx)tst-thp-1-static
-	$(SHELL) $< '' '$(test-wrapper-env)' \
+	$(BASH) $< '' '$(test-wrapper-env)' \
 		'$(run-program-env) GLIBC_TUNABLES=glibc.elf.thp=1' \
 		$(objpfx)tst-thp-1-static > $@; \
 	  $(evaluate-test)
@@ -886,7 +886,7 @@ $(objpfx)strace-tst-thp-1-static-enabled.out: \
 $(objpfx)strace-tst-thp-1-static-disabled.out: \
   $(..)sysdeps/unix/sysv/linux/strace-tst-thp.sh \
   $(objpfx)tst-thp-1-static
-	$(SHELL) $< '' '$(test-wrapper-env)' \
+	$(BASH) $< '' '$(test-wrapper-env)' \
 		'$(run-program-env) GLIBC_TUNABLES=glibc.elf.thp=0' \
 		$(objpfx)tst-thp-1-static > $@; \
 	  $(evaluate-test)
@@ -894,7 +894,7 @@ $(objpfx)strace-tst-thp-1-static-disabled.out: \
 $(objpfx)strace-tst-thp-align-default.out: \
   $(..)sysdeps/unix/sysv/linux/strace-tst-thp.sh $(objpfx)ld.so \
   $(objpfx)tst-thp-align $(objpfx)tst-thp-size-mod.so
-	$(SHELL) $< '$(strace-test-via-rtld-prefix)' \
+	$(BASH) $< '$(strace-test-via-rtld-prefix)' \
 		'$(test-wrapper-env)' '$(run-program-env)' \
 		$(objpfx)tst-thp-align > $@; \
 	  $(evaluate-test)
@@ -902,7 +902,7 @@ $(objpfx)strace-tst-thp-align-default.out: \
 $(objpfx)strace-tst-thp-align-enabled.out: \
   $(..)sysdeps/unix/sysv/linux/strace-tst-thp.sh $(objpfx)ld.so \
   $(objpfx)tst-thp-align $(objpfx)tst-thp-size-mod.so
-	$(SHELL) $< '$(strace-test-via-rtld-prefix)' \
+	$(BASH) $< '$(strace-test-via-rtld-prefix)' \
 		'$(test-wrapper-env)' \
 		'$(run-program-env) GLIBC_TUNABLES=glibc.elf.thp=1' \
 		$(objpfx)tst-thp-align > $@; \
@@ -911,7 +911,7 @@ $(objpfx)strace-tst-thp-align-enabled.out: \
 $(objpfx)strace-tst-thp-align-disabled.out: \
   $(..)sysdeps/unix/sysv/linux/strace-tst-thp.sh $(objpfx)ld.so \
   $(objpfx)tst-thp-align $(objpfx)tst-thp-size-mod.so
-	$(SHELL) $< '$(strace-test-via-rtld-prefix)' \
+	$(BASH) $< '$(strace-test-via-rtld-prefix)' \
 		'$(test-wrapper-env)' \
 		'$(run-program-env) GLIBC_TUNABLES=glibc.elf.thp=0' \
 		$(objpfx)tst-thp-align > $@; \
diff --git a/sysdeps/unix/sysv/linux/strace-tst-thp.sh b/sysdeps/unix/sysv/linux/strace-tst-thp.sh
index bff7d3e7a0..689bdc7777 100644
--- a/sysdeps/unix/sysv/linux/strace-tst-thp.sh
+++ b/sysdeps/unix/sysv/linux/strace-tst-thp.sh
@@ -17,8 +17,6 @@
 # License along with the GNU C Library; if not, see
 # <https://www.gnu.org/licenses/>.
 
-set -e
-
 rtld="$1"
 test_wrapper_env="$2"
 run_program_env="$3"
@@ -39,24 +37,24 @@ esac
 
 # Verify strace is not just present, but works in this environment.  If
 # not, skip the test.
-/bin/sh -c \
- "${test_wrapper_env} ${run_program_env} \
-  strace -X raw -e trace=none -- /bin/true" > /dev/null 2>&1 || exit 77
+${test_wrapper_env} ${run_program_env} \
+  strace -X raw -e trace=none -- /bin/true > /dev/null 2>&1 || exit 77
 
 # Finally the actual test inside the test environment, using the just
 # build ld.so and new libraries to run the THP test under strace.
-if /bin/sh -c \
-  "timeout -k 4 $((3*$TIMEOUTFACTOR)) ${cmd} --direct 2>&1 \
-   | grep -E \"madvise\(0x[0-9a-f]+, [0-9]+, 0xe)\""; then
+output=$(timeout -k 4 $((3*$TIMEOUTFACTOR)) ${cmd} --direct 2>&1)
+test $? = 77 && exit 77
+if echo "${output}" | grep -E "madvise\(0x[0-9a-f]+, [0-9]+, 0xe)"; then
   if test ${strace_expected} = yes; then
-    exit 0
+    status=0
   else
-    exit 1
+    status=1
   fi
 else
   if test ${strace_expected} = no; then
-    exit 0
+    status=0
   else
-    exit 1
+    status=1
   fi
 fi
+exit ${status}
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.