On 20/10/2026 04:43, Collin Funk wrote:
Bruno Haible <[email protected]> writes:

Collin Funk wrote:
I pushed the attached patch to fix it.

Thanks. "make distcheck" now succeeds. But a build with sanitizers fails
due to this test:

[...]

++ cmd_exe coreutils
+++ command -v coreutils
++ local found_cmd=/usr/bin/coreutils
++++ command -v env
+++ dirname 
/home/runner/work/ci-check/ci-check/coreutils-2026-10-19/build/./src/env
++ local 
found_dir=/home/runner/work/ci-check/ci-check/coreutils-2026-10-19/build/./src
++ local 
built_cmd=/home/runner/work/ci-check/ci-check/coreutils-2026-10-19/build/src/coreutils
++ test -x /usr/bin/coreutils
++ printf '%s\n' /usr/bin/coreutils
+ single_binary=/usr/bin/coreutils
+ test -n /usr/bin/coreutils
+ /usr/bin/coreutils --coreutils-prog=cat /dev/null

Sigh... I spent an unfortunate amount of time confused about why this
did not fail for me before I noticed this.

Unfortunely, GitHub Actions uses an distribution which I will leave
unnamed, whos leadership has decided their primary purpose is to replace
GNU coreutils over the past year and a half.

Anyways, thanks for the report, fixed with the attached patch.

Collin

I'd prefer not to introduce more $abs_top_builddir references if possible.
How about we just warn about and avoid found coreutils dispatchers?
I also noticed other questionable uses of $abs_top_builddir in tests/
which I've also cleaned up in the attached.

cheers,
Padraig
From ad7e743cffdae096da20f5bb43aeea09a25eca86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Tue, 20 Oct 2026 16:03:38 +0100
Subject: [PATCH] tests: avoid use of $abs_top_builddir where possible

* init.cfg (single_binary_build_): An abstraction to check
if the current build is a functional --enable-single-binary build.
(require_safe_builddir_): Also add an abstraction to check for
whitespace in $abs_top_builddir.
* tests/misc/proc-self-comm.sh: Just warn about a non functional
dispatch binary.
* tests/install/basic-1.sh: Use the abstraction which is more accurate
when a stub src/coreutils binary is present.
Also fix up an incorrect skip_ edge case.
* tests/misc/responsive.sh: Use require_safe_builddir_.
* tests/misc/stdbuf.sh: Likewise.
* tests/misc/exec-bad-unicode.sh: Clarify a comment.
---
 init.cfg                       | 19 +++++++++++++++++++
 tests/install/basic-1.sh       | 12 +++++-------
 tests/misc/exec-bad-unicode.sh |  7 ++++---
 tests/misc/proc-self-comm.sh   |  9 +++------
 tests/misc/responsive.sh       |  7 +------
 tests/misc/stdbuf.sh           |  7 +------
 6 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/init.cfg b/init.cfg
index c79a86178..531bc386e 100644
--- a/init.cfg
+++ b/init.cfg
@@ -354,6 +354,13 @@ require_built_()
   test $skip_ = yes && skip_ "required program(s) not built"
 }
 
+# Return true if the just-built coreutils can run a built-in program.
+single_binary_build_()
+{
+  "$abs_top_builddir/src/coreutils$EXEEXT" --coreutils-prog=true \
+    > /dev/null 2>&1
+}
+
 # Return the file for a command.
 # Warn and fail if not found.
 cmd_exe()
@@ -368,6 +375,18 @@ cmd_exe()
   { warn_ "unable to find $1 command"; return 1; }
 }
 
+# Skip if whitespace in $abs_top_builddir
+# as that impacts tokenization in shebangs or LD_PRELOAD for example.
+require_safe_builddir_()
+{
+  lf='
+'
+  case $abs_top_builddir in
+    *[\\\"\#\$\&\'\`$lf\ \	]*)
+      skip_ "unsafe absolute build directory name: $abs_top_builddir";;
+  esac
+}
+
 require_file_system_bytes_free_()
 {
   local req=$1
diff --git a/tests/install/basic-1.sh b/tests/install/basic-1.sh
index 99434ccaa..dcc8b77de 100755
--- a/tests/install/basic-1.sh
+++ b/tests/install/basic-1.sh
@@ -54,17 +54,15 @@ dd2=dd2$EXEEXT
 
 just_built_dd=$abs_top_builddir/src/$dd
 
-test -r "$just_built_dd" \
-  || warn_ "WARNING!!! Your just-built dd binary, $just_built_dd
-is not readable, so skipping the remaining tests in this file."
+test -r "$just_built_dd" || skip_ "Missing $just_built_dd binary"
 
-cp "$just_built_dd" . || fail=1
-cp $dd $dd2 || fail=1
+cp "$just_built_dd" . &&
+cp $dd $dd2 || framework_failure_
 
 strip=-s
 if ! strip $dd2; then
-  ! test -e $abs_top_builddir/src/coreutils \
-    && warn_ "WARNING!!! Your strip command doesn't seem to work,
+  ! single_binary_build_ \
+    && warn_ "Warning: Your strip command doesn't seem to work,
 so skipping the test of install's --strip option."
   strip=
 fi
diff --git a/tests/misc/exec-bad-unicode.sh b/tests/misc/exec-bad-unicode.sh
index abd5ee9d5..c9e062e60 100755
--- a/tests/misc/exec-bad-unicode.sh
+++ b/tests/misc/exec-bad-unicode.sh
@@ -27,9 +27,10 @@ printf '#!%s\n' "$(cmd_exe echo)" >"$script" ||
   skip_ 'bad unicode not supported in shell or file system'
 chmod u+x "$script" || framework_failure_
 
-# Check that it can be executed, which is not the case if there are
-# spaces in $abs_top_builddir.  Such spaces also preclude stdbuf's
-# LD_PRELOAD from operating correctly.
+# Check that it can be executed, which is also not the case if
+# spaces in the path.  Such spaces also preclude stdbuf's
+# LD_PRELOAD from operating correctly.  This is a more direct
+# check than using require_safe_builddir_.
 ./"$script" "$script" >exp \
   || skip_ 'cannot execute a file name with invalid unicode'
 
diff --git a/tests/misc/proc-self-comm.sh b/tests/misc/proc-self-comm.sh
index 6d1d58aee..dc0140b2c 100755
--- a/tests/misc/proc-self-comm.sh
+++ b/tests/misc/proc-self-comm.sh
@@ -24,13 +24,10 @@ test -f /proc/self/comm || skip_ '/proc/self/comm is required'
 # Set up variables to execute 'cat' from its absolute path and,
 # if available, through the single binary.
 abs_cat=$(cmd_exe cat) || framework_failure_
-single_binary="$abs_top_builddir/src/coreutils$EXEEXT"
+single_binary=$(cmd_exe coreutils)
 
-if ! test -x "$single_binary"; then
-  single_binary=
-elif test -n "$single_binary" &&
-    ! "$single_binary" --coreutils-prog=cat /dev/null 2>err; then
-  grep "^coreutils: unknown program 'cat'$" err || framework_failure_
+if test -n "$single_binary" && ! single_binary_build_; then
+  warn_ "Warning: ignoring single binary dispatcher: $single_binary"
   single_binary=
 fi
 
diff --git a/tests/misc/responsive.sh b/tests/misc/responsive.sh
index a63b55ca1..11e07d880 100755
--- a/tests/misc/responsive.sh
+++ b/tests/misc/responsive.sh
@@ -21,12 +21,7 @@ print_ver_ stdbuf
 
 # stdbuf fails when the absolute top build dir name contains e.g.,
 # space, TAB, NL
-lf='
-'
-case $abs_top_builddir in
-  *[\\\"\#\$\&\'\`$lf\ \	]*)
-    skip_ "unsafe absolute build directory name: $abs_top_builddir";;
-esac
+require_safe_builddir_
 
 stdbuf -oL true || skip_ 'stdbuf not supported'
 
diff --git a/tests/misc/stdbuf.sh b/tests/misc/stdbuf.sh
index 170d25c5f..c5c965cba 100755
--- a/tests/misc/stdbuf.sh
+++ b/tests/misc/stdbuf.sh
@@ -23,12 +23,7 @@ getlimits_
 
 # stdbuf fails when the absolute top build dir name contains e.g.,
 # space, TAB, NL
-lf='
-'
-case $abs_top_builddir in
-  *[\\\"\#\$\&\'\`$lf\ \	]*)
-    skip_ "unsafe absolute build directory name: $abs_top_builddir";;
-esac
+require_safe_builddir_
 
 # Use a fifo rather than a pipe in the tests below
 # so that the producer (uniq) will wait until the
-- 
2.55.0

Reply via email to