Util-Linux Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] Fix mountpoint test failure in build chroots.
@ 2020-06-22 23:52 Chris Hofstaedtler
  2020-06-24 13:46 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Hofstaedtler @ 2020-06-22 23:52 UTC (permalink / raw)
  To: util-linux; +Cc: Mark Hindley

From: Mark Hindley <mark@hindley.org.uk>

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  |  2 +-
 tests/expected/misc/mountpoint-nofollow |  2 +-
 tests/ts/misc/mountpoint                | 15 +++++++++++----
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/tests/expected/misc/mountpoint-default b/tests/expected/misc/mountpoint-default
index 9a7ac6ab3..ca7505538 100644
--- a/tests/expected/misc/mountpoint-default
+++ b/tests/expected/misc/mountpoint-default
@@ -1,2 +1,2 @@
-./symlink-to-root is a mountpoint
+./symlink-to-mountpoint is a mountpoint
 0
diff --git a/tests/expected/misc/mountpoint-nofollow b/tests/expected/misc/mountpoint-nofollow
index 1ba174959..03d2b5da8 100644
--- a/tests/expected/misc/mountpoint-nofollow
+++ b/tests/expected/misc/mountpoint-nofollow
@@ -1,2 +1,2 @@
-./symlink-to-root is not a mountpoint
+./symlink-to-mountpoint is not a mountpoint
 1
diff --git a/tests/ts/misc/mountpoint b/tests/ts/misc/mountpoint
index 1b391c3bf..e52ccb28f 100755
--- a/tests/ts/misc/mountpoint
+++ b/tests/ts/misc/mountpoint
@@ -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
-- 
2.27.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix mountpoint test failure in build chroots.
  2020-06-22 23:52 [PATCH] Fix mountpoint test failure in build chroots Chris Hofstaedtler
@ 2020-06-24 13:46 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2020-06-24 13:46 UTC (permalink / raw)
  To: Chris Hofstaedtler; +Cc: util-linux, Mark Hindley

On Mon, Jun 22, 2020 at 11:52:09PM +0000, Chris Hofstaedtler wrote:
>  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.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 23:52 [PATCH] Fix mountpoint test failure in build chroots Chris Hofstaedtler
2020-06-24 13:46 ` Karel Zak

Util-Linux Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/util-linux/0 util-linux/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 util-linux util-linux/ https://lore.kernel.org/util-linux \
		util-linux@vger.kernel.org
	public-inbox-index util-linux

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.util-linux


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git