]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (libmount) improve explicit loop read-write mount check
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Mon, 13 Oct 2025 18:53:59 +0000 (14:53 -0400)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Mon, 13 Oct 2025 18:53:59 +0000 (14:53 -0400)
Some kernel configurations will affect default mount behavior
and add extra mount options. As a result, the $TS_OUTPUT will not
reliably match on all kernels. Therefore it is better to simply
test whether 'rw' is an option and not write the full options
list to $TS_OUTPUT.

Adresses: #3765
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
tests/expected/libmount/loop-explicit-rw
tests/ts/libmount/loop

index e7787c0590e3e5c1da18efaa543d354511e795fc..35821117c875783dd71b802f8d48510ad857b74f 100644 (file)
@@ -1,2 +1 @@
-rw
 Success
index db807bd44ad7c22e660de53561fe508a0cb430a9..72fd27f0144fd3ee7cb940d983b36d9243517934 100755 (executable)
@@ -142,7 +142,8 @@ ts_finalize_subtest
 ts_init_subtest "explicit-rw"
 [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
 $TS_CMD_MOUNT -o rw "$BACKFILE" "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG
-$TS_CMD_FINDMNT -no FS-OPTIONS --mountpoint "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG
+FINDMNT_RES=$( $TS_CMD_FINDMNT -Q 'OPTIONS =~ "[,]?rw[,]?"' -no OPTIONS --mountpoint "$TS_MOUNTPOINT" )
+[ -n "$FINDMNT_RES" ] || ts_log "$TS_MOUNTPOINT not mounted as read-write"
 $TS_CMD_UMOUNT "$TS_MOUNTPOINT" >> $TS_OUTPUT 2>> $TS_ERRLOG
 udevadm settle
 ts_log "Success"