As mentioned in
https://lists.gnu.org/archive/html/coreutils/2026-04/msg00045.html
it is risky to test $host_triplet when it may match the VENDOR field
of CPU-VENDOR-[KERNEL-]OPERATING_SYSTEM.

Here's a proposed fix of the existing tests to avoid that.

>From 8eaaf83413c6bdd98ca7e0980b0bffea77c9327b Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Fri, 10 Apr 2026 08:13:24 +0200
Subject: [PATCH] tests: Avoid accidental matching of the vendor field of $host

* tests/chgrp/basic.sh: Test $host_os, not $host_triplet.
* tests/chown/separator.sh: Likewise.
* tests/rm/r-root.sh: Likewise.
* tests/tail/pipe-f.sh: Likewise.
* tests/tail/tail-c.sh: Likewise.
* tests/tee/tee.sh: Likewise.
* tests/touch/dangling-symlink.sh: Likewise.
---
 tests/chgrp/basic.sh            | 6 +++---
 tests/chown/separator.sh        | 4 ++--
 tests/rm/r-root.sh              | 4 ++--
 tests/tail/pipe-f.sh            | 4 ++--
 tests/tail/tail-c.sh            | 4 ++--
 tests/tee/tee.sh                | 4 ++--
 tests/touch/dangling-symlink.sh | 4 ++--
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/tests/chgrp/basic.sh b/tests/chgrp/basic.sh
index a186a70cd..1d8715efe 100755
--- a/tests/chgrp/basic.sh
+++ b/tests/chgrp/basic.sh
@@ -98,9 +98,9 @@ chgrp $g1 f
 chgrp '' f
 test "$(ls -C -c -t f g)" = 'f  g' || \
   {
-    case $host_triplet in
-      *openbsd*) echo ignoring known OpenBSD-specific chgrp failure 1>&2 ;;
-      *darwin7.9.*|*darwin8.*)
+    case $host_os in
+      openbsd*) echo ignoring known OpenBSD-specific chgrp failure 1>&2 ;;
+      darwin7.9.*|darwin8.*)
         echo ignoring known MacOS X-specific chgrp failure 1>&2 ;;
       *) echo $host_triplet: no-change chgrp failed to update ctime 1>&2;
             fail=1 ;;
diff --git a/tests/chown/separator.sh b/tests/chown/separator.sh
index 617ca0fa5..22e71d274 100755
--- a/tests/chown/separator.sh
+++ b/tests/chown/separator.sh
@@ -40,8 +40,8 @@ test $(getent group | grep "^$id_gn:" | wc -l) = 1 ||
 # FreeBSD 6.x's getgrnam fails to look up a group name containing
 # a space. On such a system, skip this test if the group name contains
 # a byte not in the portable filename character set.
-case $host_triplet in
-  *-freebsd6.*)
+case $host_os in
+  freebsd6.*)
     case $id_gn in
       *[^a-zA-Z0-9._-]*) skip_ "invalid group name: $id_gn";;
     esac;;
diff --git a/tests/rm/r-root.sh b/tests/rm/r-root.sh
index 9954ac926..aaf063ddc 100755
--- a/tests/rm/r-root.sh
+++ b/tests/rm/r-root.sh
@@ -41,8 +41,8 @@ unset CU_TEST_SKIP_EXIT
 USE_GDB=1
 
 if test $USE_GDB = 1; then
-  case $host_triplet in
-    *darwin*) skip_ 'avoiding due to potentially non functioning gdb' ;;
+  case $host_os in
+    darwin*) skip_ 'avoiding due to potentially non functioning gdb' ;;
     *) ;;
   esac
 
diff --git a/tests/tail/pipe-f.sh b/tests/tail/pipe-f.sh
index e5742c1fa..eeaa92b60 100755
--- a/tests/tail/pipe-f.sh
+++ b/tests/tail/pipe-f.sh
@@ -41,8 +41,8 @@ compare exp out || fail=1
 # Also check tail exits if SIGPIPE is being ignored.
 # Note 'trap - SIGPIPE' is ineffective if the initiating shell
 # has ignored SIGPIPE, but that's not the normal case.
-case $host_triplet in
-  *aix*) echo  'avoiding due to no way to detect closed outputs on AIX' ;;
+case $host_os in
+  aix*) echo  'avoiding due to no way to detect closed outputs on AIX' ;;
   *)
 for disposition in '' '-'; do
   (trap "$disposition" PIPE;
diff --git a/tests/tail/tail-c.sh b/tests/tail/tail-c.sh
index 56f97d79f..33058751f 100755
--- a/tests/tail/tail-c.sh
+++ b/tests/tail/tail-c.sh
@@ -49,8 +49,8 @@ if test -r /dev/urandom; then
       # Solaris 11 allows negative seek but then gives EINVAL on read
       1) grep 'Invalid argument' err || fail=1;;
       *)
-        case $host_triplet in
-          *linux-gnu*)
+        case $host_os in
+          linux-gnu*)
             case "$(uname -r)" in
               [12].*) ;;  # Older Linux versions timeout
               *) fail=1 ;;
diff --git a/tests/tee/tee.sh b/tests/tee/tee.sh
index 41d1b9acd..e102d7027 100755
--- a/tests/tee/tee.sh
+++ b/tests/tee/tee.sh
@@ -63,8 +63,8 @@ if test -w /dev/full && test -c /dev/full; then
   test $(wc -l < err) = 1 || { cat err; fail=1; }
 fi
 
-case $host_triplet in
-  *aix*) echo  'avoiding due to no way to detect closed outputs on AIX' ;;
+case $host_os in
+  aix*) echo  'avoiding due to no way to detect closed outputs on AIX' ;;
   *)
 # Test iopoll-powered early exit for closed pipes
 tee_exited() { sleep $1; test -f tee.exited; }
diff --git a/tests/touch/dangling-symlink.sh b/tests/touch/dangling-symlink.sh
index 863cf4fc9..e57e2641e 100755
--- a/tests/touch/dangling-symlink.sh
+++ b/tests/touch/dangling-symlink.sh
@@ -30,8 +30,8 @@ test -f touch-target || fail=1
 rm -f touch-target t-symlink
 
 if test $fail = 1; then
-  case $host_triplet in
-    *linux-gnu*)
+  case $host_os in
+    linux-gnu*)
       case "$(uname -r)" in
         2.3.9[0-9]*)
           skip_ \
-- 
2.52.0

  • [PATCH] tests: Avoid acc... Bruno Haible via GNU coreutils General Discussion

Reply via email to