When testing on some hosts on the GCC server farm, I noticed the new
'tests/find/mount-vs-xdev.sh' and the older 'tests/find/user-group-max.sh'
failing, i.e., a test framework failure, not a bug in the tool under test.

The attached fixes those.

* [PATCH 1/2] tests: make new -mount test more robust
* [PATCH 2/2] tests: avoid unportable 'sed -i'

Have a nice day,
Berny
From ebea22e88b52ff70a213ffa128d740e13b8f958e Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email protected]>
Date: Mon, 5 Jan 2026 18:25:08 +0100
Subject: [PATCH 1/2] tests: make new -mount test more robust

This test failed on non-Linux systems:
- On Solaris 11, the output of the native df(1) tool has a different order,
  and hence the detection of a usable mount point for the test fails.
  Verify that df(1) is from GNU coreutils, or fall back to 'gdf',
  else skip the test.
- On a FreeBSD system where /home was a symlink to /usr/home, the code
  for finding a usable mount point failed, because the symlink itself
  is on the '/' file system.
  Ensure that the found mount point is identical to the original test
  directory like /home etc.

* tests/find/mount-vs-xdev.sh: Try harder to use a GNU df(1) tool.
Check whether the found mount point is identical to the original
directory name, thus avoiding symlinks.
---
 tests/find/mount-vs-xdev.sh | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tests/find/mount-vs-xdev.sh b/tests/find/mount-vs-xdev.sh
index 9007a81e..1dca346d 100755
--- a/tests/find/mount-vs-xdev.sh
+++ b/tests/find/mount-vs-xdev.sh
@@ -19,9 +19,17 @@
 . "${srcdir=.}/tests/init.sh"; fu_path_prepend_
 print_ver_ find
 
+# Require GNU df in getmntpoint.
+for f in df gdf; do
+  # Find GNU df.
+  $f --version | grep GNU \
+    && DF=$f
+done
+test "$DF" || skip_ "GNU df required."
+
 getmntpoint () {
   # Skip header line and print last field.
-  df "$1" | awk 'NR==2 {print $NF}'
+  $DF "$1" | awk 'NR==2 {print $NF}'
 }
 
 mnt_root=$( getmntpoint '/' ) \
@@ -32,9 +40,10 @@ found=0
 # Find a directory entry which is mounted (likely) from a different device
 # than the '/' directory.
 for m in /dev /home /proc /run /tmp; do
-  test -e "$m" \
+  test -d "$m" \
     && mnt_m=$( getmntpoint "$m" )  \
     && test "$mnt_root" != "$mnt_m" \
+    && test "$m" = "$mnt_m" \
     || continue
 
   found=1
-- 
2.52.0

From 99b3365ec386f90a930b9e4964750ce87e411152 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email protected]>
Date: Mon, 5 Jan 2026 23:43:02 +0100
Subject: [PATCH 2/2] tests: avoid unportable 'sed -i'

The sed(1) implementations at least on Solaris and the BSD familiy OSes do
not support the -i flag, and latest POSIX 2024 still does not specify it.

* tests/find/user-group-max.sh: Avoid 'sed -i' by redirecting to
another file ERR2.
---
 tests/find/user-group-max.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/find/user-group-max.sh b/tests/find/user-group-max.sh
index ab42b1bf..01c17c2e 100755
--- a/tests/find/user-group-max.sh
+++ b/tests/find/user-group-max.sh
@@ -40,12 +40,12 @@ compare /dev/null err || fail=1
 # Verify that UID/GID numbers larger than UID_T_MAX/GID_T_MAX get rejected.
 echo "find: invalid user name or UID argument to -user: '$UID_T_OFLOW'" >exp || framework_failure_
 returns_ 1 find -user "$UID_T_OFLOW" -name enoent >/dev/null 2>err || fail=1
-sed -i 's/^.*find/find/' err || framework_failure_
-compare exp err || fail=1
+sed 's/^.*find/find/' err > err2 || framework_failure_
+compare exp err2 || fail=1
 
 echo "find: invalid group name or GID argument to -group: '$GID_T_OFLOW'" >exp || framework_failure_
 returns_ 1 find -group "$GID_T_OFLOW" -name enoent >/dev/null 2>err || fail=1
-sed -i 's/^.*find/find/' err || framework_failure_
-compare exp err || fail=1
+sed 's/^.*find/find/' err > err2 || framework_failure_
+compare exp err2 || fail=1
 
 Exit $fail
-- 
2.52.0

Reply via email to