]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: Fix mountpoint test failure in build chroots.
authorMark Hindley <mark@hindley.org.uk>
Mon, 22 Jun 2020 23:52:09 +0000 (23:52 +0000)
committerKarel Zak <kzak@redhat.com>
Wed, 24 Jun 2020 13:44:44 +0000 (15:44 +0200)
The test assumed that / was a mountpoint. This is not always the case, for
example in pbuilder/cowbuilder chroots. So use / if findmnt verifies it is a
mountpoint, otherwise use the first mountpoint found. Skip the test if no
mountpoints are found.

Signed-off-by: Mark Hindley <mark@hindley.org.uk>
tests/expected/misc/mountpoint-default
tests/expected/misc/mountpoint-nofollow
tests/ts/misc/mountpoint

index 9a7ac6ab31b2631b782cc10a12fbb18d81bf31b0..ca75055384b57fdc233ac1ea5b1c5ace4c29eedc 100644 (file)
@@ -1,2 +1,2 @@
-./symlink-to-root is a mountpoint
+./symlink-to-mountpoint is a mountpoint
 0
index 1ba1749599ceed4c3d0b336208577313fd218ee7..03d2b5da89bcd34b2dc3434147c2765d26113ea3 100644 (file)
@@ -1,2 +1,2 @@
-./symlink-to-root is not a mountpoint
+./symlink-to-mountpoint is not a mountpoint
 1
index 1b391c3bfbbcb38445de78ee456a7641ebb436b8..e52ccb28fb5701c005400c19841883b016c3f3ad 100755 (executable)
@@ -7,16 +7,23 @@ TS_DESC="mountpoint"
 ts_init "$*"
 
 ts_check_test_command "$TS_CMD_MOUNTPOINT"
+ts_check_test_command "$TS_CMD_FINDMNT"
 
-ln -s / ./symlink-to-root
+# / is not always a mountpoint (chroots etc.), so check if it is and otherwise
+# fallback to the first available mountpoint.
+FIRST_MOUNTPOINT=$($TS_CMD_FINDMNT -no TARGET / || $TS_CMD_FINDMNT -fno TARGET)
+
+[ -z "$FIRST_MOUNTPOINT" ] && ts_skip "no mountpoint found for symlink tests"
+
+ln -s $FIRST_MOUNTPOINT ./symlink-to-mountpoint
 
 ts_init_subtest "default"
-$TS_CMD_MOUNTPOINT ./symlink-to-root >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNTPOINT ./symlink-to-mountpoint >> $TS_OUTPUT 2>> $TS_ERRLOG
 echo $? >> $TS_OUTPUT 2>> $TS_ERRLOG
 ts_finalize_subtest
 
 ts_init_subtest "nofollow"
-$TS_CMD_MOUNTPOINT --nofollow ./symlink-to-root >> $TS_OUTPUT 2>> $TS_ERRLOG
+$TS_CMD_MOUNTPOINT --nofollow ./symlink-to-mountpoint >> $TS_OUTPUT 2>> $TS_ERRLOG
 echo $? >> $TS_OUTPUT 2>> $TS_ERRLOG
 ts_finalize_subtest
 
@@ -25,5 +32,5 @@ $TS_CMD_MOUNTPOINT --devno --nofollow / >> $TS_OUTPUT 2>> $TS_ERRLOG
 echo $? >> $TS_OUTPUT 2>> $TS_ERRLOG
 ts_finalize_subtest
 
-rm -f ./symlink-to-root
+rm -f ./symlink-to-mountpoint
 ts_finalize