Skip to contentSkip to conversation

Fix mountpoint test failure in build chroots.

PATCH Applied Chris Hofstaedtler 2 participants 2 messages Jun 22, 2020 – Jun 24, 2020 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix mountpoint test failure in build chroots.

From: Mark Hindley <[email protected]>

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.

---
 tests/expected/misc/mountpoint-default  |  2 +-
 tests/expected/misc/mountpoint-nofollow |  2 +-
 tests/ts/misc/mountpoint                | 15 +++++++++++----
 3 files changed, 13 insertions(+), 6 deletions(-)
tests/expected/misc/mountpoint-default +1 -1
index 9a7ac6ab3..ca7505538 100644
@@ -1,2 +1,2 @@
-./symlink-to-root is a mountpoint
+./symlink-to-mountpoint is a mountpoint
 0
tests/expected/misc/mountpoint-nofollow +1 -1
index 1ba174959..03d2b5da8 100644
@@ -1,2 +1,2 @@
-./symlink-to-root is not a mountpoint
+./symlink-to-mountpoint is not a mountpoint
 1
tests/ts/misc/mountpoint +11 -4
index 1b391c3bf..e52ccb28f 100755
@@ -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
Signature · 1 line
2.27.0
maintainer Applied
#1 lore raw
Quoted 4 lines · Chris Hofstaedtler
 tests/expected/misc/mountpoint-default  |  2 +-
 tests/expected/misc/mountpoint-nofollow |  2 +-
 tests/ts/misc/mountpoint                | 15 +++++++++++----
 3 files changed, 13 insertions(+), 6 deletions(-)

Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com