]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
tests: improve reliability of run-sysroot.sh users/amerey/try-sysroot-test
authorArnout Engelen <arnout@bzzt.net>
Fri, 5 Dec 2025 14:52:41 +0000 (15:52 +0100)
committerAaron Merey <amerey@redhat.com>
Tue, 9 Dec 2025 15:07:35 +0000 (10:07 -0500)
Previously, the 'second' test would test the `RESOLVE_IN_ROOT` feature
when the current libc supports it, even when the currently running
kernel did not yet support it.

Signed-off-by: Arnout Engelen <arnout@bzzt.net>
tests/run-sysroot.sh

index fe30244619107da502e45db57bea048eac103337..d2041e8ab5e709bc616c557b1a52277d02e027fc 100755 (executable)
@@ -46,10 +46,14 @@ TID 431185:
 #8  0x0000aaaae56127f0 _start
 EOF
 
-HAVE_OPENAT2=$(grep '^#define HAVE_OPENAT2_RESOLVE_IN_ROOT' \
-                    ${abs_builddir}/../config.h | awk '{print $3}')
+libc_has_openat2_resolve_in_root() {
+  grep '^#define HAVE_OPENAT2_RESOLVE_IN_ROOT' ${abs_builddir}/../config.h | awk '{print $3}'
+}
+kernel_has_openat2_resolve_in_root() {
+  printf "%s\n%s" "5.6.0" "$(uname -r)" | sort -V -C
+}
 
-if [[ "$HAVE_OPENAT2" = 1 ]]; then
+if libc_has_openat2_resolve_in_root && kernel_has_openat2_resolve_in_root; then
     # Change the layout of files in sysroot to test symlink escape scenario
     rm -f "${tmpdir}/sysroot/bin"
     mkdir "${tmpdir}/sysroot/bin"
@@ -57,7 +61,8 @@ if [[ "$HAVE_OPENAT2" = 1 ]]; then
     ln -s /bin/bash "${tmpdir}/sysroot/usr/bin/bash"
 
     # Check that stack with --sysroot generates correct backtrace even if target
-    # binary is actually absolute symlink pointing outside of sysroot directory
+    # binary is actually absolute symlink to be interpreted relative to the sysroot
+    # directory
     testrun "${abs_top_builddir}"/src/stack --core "${tmpdir}/core.bash" \
            --sysroot "${tmpdir}/sysroot" >"${tmpdir}/stack.out"