summaryrefslogtreecommitdiffstats
path: root/tests/ts/eject
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 02:42:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 02:42:50 +0000
commit8cb83eee5a58b1fad74c34094ce3afb9e430b5a4 (patch)
treea9b2e7baeca1be40eb734371e3c8b11b02294497 /tests/ts/eject
parentInitial commit. (diff)
downloadutil-linux-upstream.tar.xz
util-linux-upstream.zip
Adding upstream version 2.33.1.upstream/2.33.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xtests/ts/eject/umount112
1 files changed, 112 insertions, 0 deletions
diff --git a/tests/ts/eject/umount b/tests/ts/eject/umount
new file mode 100755
index 0000000..9faab27
--- /dev/null
+++ b/tests/ts/eject/umount
@@ -0,0 +1,112 @@
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="umount"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_FDISK"
+ts_check_test_command "$TS_CMD_EJECT"
+ts_check_test_command "$TS_CMD_MOUNT"
+
+ts_skip_nonroot
+ts_check_prog "mkfs.ext2"
+
+# scsi_debug could not eject for kernel >=3.19 and <4.4
+if x=$(echo "3.19" && uname -r && echo "4.4") \
+ && test "$x" = "$(echo "$x" | sort --version-sort)"
+then
+ ts_skip "3.19 <= $(uname -sr) < 4.4"
+fi
+
+#
+# Note that eject --force is required because scsi_debug is
+# not removable device.
+#
+
+# set global variable TS_DEVICE
+function init_device {
+ ts_scsi_debug_init dev_size_mb=100
+}
+
+function init_partitions {
+ local dev=$1
+
+ ts_log "Create partitions"
+ $TS_CMD_FDISK $dev >> /dev/null 2>&1 <<EOF
+n
+p
+1
+
++50M
+n
+p
+2
+
+
+p
+w
+EOF
+ udevadm settle
+ mkfs.ext2 -q ${dev}1
+ mkfs.ext2 -q ${dev}2
+ udevadm settle
+}
+
+function deinit_device {
+ ts_scsi_debug_rmmod
+}
+
+
+ts_init_subtest "by-disk"
+init_device
+$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
+deinit_device
+ts_finalize_subtest
+
+
+ts_init_subtest "by-disk-mounted"
+init_device
+mkfs.ext2 -q -F $TS_DEVICE
+udevadm settle
+mkdir -p $TS_MOUNTPOINT
+$TS_CMD_MOUNT $TS_DEVICE $TS_MOUNTPOINT
+$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
+deinit_device
+ts_finalize_subtest
+
+
+ts_init_subtest "by-disk-mounted-partition"
+init_device
+init_partitions $TS_DEVICE
+mkdir -p ${TS_MOUNTPOINT}1
+mkdir -p ${TS_MOUNTPOINT}2
+$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1
+$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2
+$TS_CMD_EJECT --force $TS_DEVICE && ts_log "Success"
+deinit_device
+ts_finalize_subtest
+
+
+ts_init_subtest "by-partition"
+init_device
+init_partitions $TS_DEVICE
+$TS_CMD_EJECT --force ${TS_DEVICE}1 && ts_log "Success"
+deinit_device
+ts_finalize_subtest
+
+
+ts_init_subtest "by-partition-mounted"
+init_device
+init_partitions $TS_DEVICE
+mkdir -p ${TS_MOUNTPOINT}1
+mkdir -p ${TS_MOUNTPOINT}2
+$TS_CMD_MOUNT ${TS_DEVICE}1 ${TS_MOUNTPOINT}1
+$TS_CMD_MOUNT ${TS_DEVICE}2 ${TS_MOUNTPOINT}2
+$TS_CMD_EJECT --force ${TS_DEVICE}1 && ts_log "Success"
+deinit_device
+ts_finalize_subtest
+
+
+ts_finalize