]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mount: (tests) test fallback codepaths
authorThomas Weißschuh <thomas@t-8ch.de>
Mon, 24 Apr 2023 17:11:03 +0000 (19:11 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Mon, 24 Apr 2023 20:05:55 +0000 (22:05 +0200)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
tests/ts/mount/fallback [new file with mode: 0755]

diff --git a/tests/ts/mount/fallback b/tests/ts/mount/fallback
new file mode 100755 (executable)
index 0000000..d8f3732
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="fstab-fallback"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_HELPER_ENOSYS"
+ts_check_test_command "$TS_CMD_MOUNT"
+ts_check_test_command "$TS_CMD_UMOUNT"
+ts_check_test_command "$TS_CMD_FINDMNT"
+
+ts_skip_nonroot
+
+test_mount_fallback() {
+       ts_init_subtest "$1"
+
+       MY_SOURCE="${TS_MOUNTPOINT}-src"
+
+       mkdir -p "$MY_SOURCE"
+       mkdir -p "$TS_MOUNTPOINT"
+
+       "$TS_HELPER_ENOSYS" $2 -- "$TS_CMD_MOUNT" --bind "$MY_SOURCE" "$TS_MOUNTPOINT" \
+               >> "$TS_OUTPUT" 2>> "$TS_ERRLOG"
+       [ "$?" = "0" ] || ts_log "error: mount $TS_MOUNTPOINT"
+
+       "$TS_CMD_FINDMNT" --mountpoint "$TS_MOUNTPOINT" &> /dev/null
+       [ $? -eq 0 ] || ts_die "Not found target (mount failed?)"
+
+       "$TS_CMD_UMOUNT" "$TS_MOUNTPOINT" || ts_die "Cannot umount $TS_MOUNTPOINT"
+
+       ts_finalize_subtest
+}
+
+test_mount_fallback "open_tree" "-s open_tree"
+test_mount_fallback "fsopen" "-s fsopen"
+
+ts_fstab_clean
+
+ts_finalize
+