From ebea22e88b52ff70a213ffa128d740e13b8f958e Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Mon, 5 Jan 2026 18:25:08 +0100 Subject: [PATCH] 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