diff options
author | Karel Zak <kzak@redhat.com> | 2012-03-29 12:50:50 +0200 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2012-03-29 12:50:50 +0200 |
commit | 6030230e4bb30620501e93073a06a69d9773504b (patch) | |
tree | 5cf75ee443cca0a2189a99f84cbc350ea0cc0f62 /tests | |
parent | 9b439aa9471ae7db160b3b1a27d9039dc7fa2991 (diff) | |
download | util-linux-6030230e4bb30620501e93073a06a69d9773504b.tar.gz |
tests: add umount-by-eject tests
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/commands.sh.in | 1 | ||||
-rw-r--r-- | tests/expected/eject/umount | 0 | ||||
-rw-r--r-- | tests/expected/eject/umount-by-disk | 1 | ||||
-rw-r--r-- | tests/expected/eject/umount-by-disk-mounted | 1 | ||||
-rw-r--r-- | tests/expected/eject/umount-by-disk-mounted-partition | 2 | ||||
-rw-r--r-- | tests/expected/eject/umount-by-partition | 2 | ||||
-rw-r--r-- | tests/expected/eject/umount-by-partition-mounted | 2 | ||||
-rwxr-xr-x | tests/ts/eject/umount | 106 |
8 files changed, 115 insertions, 0 deletions
diff --git a/tests/commands.sh.in b/tests/commands.sh.in index 1ce112a5..7e34f7a2 100644 --- a/tests/commands.sh.in +++ b/tests/commands.sh.in @@ -62,6 +62,7 @@ TS_CMD_NAMEI=${TS_CMD_NAMEI-"$top_builddir/misc-utils/namei"} TS_CMD_LOOK=${TS_CMD_LOOK-"$top_builddir/misc-utils/look"} TS_CMD_CAL=${TS_CMD_CAL-"$top_builddir/misc-utils/cal"} TS_CMD_SCRIPT=${TS_CMD_SCRIPT-"$top_builddir/term-utils/script"} +TS_CMD_EJECT=${TS_CMD_EJECT-"$top_builddir/misc-utils/eject"} TS_CMD_HWCLOCK=${TS_CMD_HWCLOCK-"$top_builddir/hwclock/hwclock"} diff --git a/tests/expected/eject/umount b/tests/expected/eject/umount new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/expected/eject/umount diff --git a/tests/expected/eject/umount-by-disk b/tests/expected/eject/umount-by-disk new file mode 100644 index 00000000..35821117 --- /dev/null +++ b/tests/expected/eject/umount-by-disk @@ -0,0 +1 @@ +Success diff --git a/tests/expected/eject/umount-by-disk-mounted b/tests/expected/eject/umount-by-disk-mounted new file mode 100644 index 00000000..35821117 --- /dev/null +++ b/tests/expected/eject/umount-by-disk-mounted @@ -0,0 +1 @@ +Success diff --git a/tests/expected/eject/umount-by-disk-mounted-partition b/tests/expected/eject/umount-by-disk-mounted-partition new file mode 100644 index 00000000..2a99ba0b --- /dev/null +++ b/tests/expected/eject/umount-by-disk-mounted-partition @@ -0,0 +1,2 @@ +Create partitions +Success diff --git a/tests/expected/eject/umount-by-partition b/tests/expected/eject/umount-by-partition new file mode 100644 index 00000000..2a99ba0b --- /dev/null +++ b/tests/expected/eject/umount-by-partition @@ -0,0 +1,2 @@ +Create partitions +Success diff --git a/tests/expected/eject/umount-by-partition-mounted b/tests/expected/eject/umount-by-partition-mounted new file mode 100644 index 00000000..2a99ba0b --- /dev/null +++ b/tests/expected/eject/umount-by-partition-mounted @@ -0,0 +1,2 @@ +Create partitions +Success diff --git a/tests/ts/eject/umount b/tests/ts/eject/umount new file mode 100755 index 00000000..28f286cc --- /dev/null +++ b/tests/ts/eject/umount @@ -0,0 +1,106 @@ +#!/bin/bash + +TS_TOPDIR="$(dirname $0)/../.." +TS_DESC="umount" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +modprobe --dry-run --quiet scsi_debug +[ "$?" == 0 ] || ts_skip "missing scsi_debug module" + +rmmod scsi_debug &> /dev/null + +function init_device { + modprobe scsi_debug dev_size_mb=100 + [ "$?" == 0 ] || ts_die "Cannot init device" + + sleep 3 + + DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}') + [ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device" + + echo "/dev/${DEVNAME}" + +} + +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 + sleep 1 + mkfs.ext2 -q ${dev}1 + mkfs.ext2 -q ${dev}2 +} + +function deinit_device { + sleep 3 + rmmod scsi_debug +} + + +ts_init_subtest "by-disk" +DEVICE=$(init_device) +$TS_CMD_EJECT $DEVICE && ts_log "Success" +deinit_device +ts_finalize_subtest + +ts_init_subtest "by-disk-mounted" +DEVICE=$(init_device) +mkfs.ext2 -q -F $DEVICE +mkdir -p $TS_MOUNTPOINT +mount $DEVICE $TS_MOUNTPOINT +sleep 1 +$TS_CMD_EJECT $DEVICE && ts_log "Success" +deinit_device +ts_finalize_subtest + + +ts_init_subtest "by-disk-mounted-partition" +DEVICE=$(init_device) +init_partitions $DEVICE +mkdir -p ${TS_MOUNTPOINT}1 +mkdir -p ${TS_MOUNTPOINT}2 +mount ${DEVICE}1 ${TS_MOUNTPOINT}1 +mount ${DEVICE}2 ${TS_MOUNTPOINT}2 +$TS_CMD_EJECT $DEVICE && ts_log "Success" +deinit_device +ts_finalize_subtest + + +ts_init_subtest "by-partition" +DEVICE=$(init_device) +init_partitions $DEVICE +$TS_CMD_EJECT ${DEVICE}1 && ts_log "Success" +deinit_device +ts_finalize_subtest + + +ts_init_subtest "by-partition-mounted" +DEVICE=$(init_device) +init_partitions $DEVICE +mkdir -p ${TS_MOUNTPOINT}1 +mkdir -p ${TS_MOUNTPOINT}2 +mount ${DEVICE}1 ${TS_MOUNTPOINT}1 +mount ${DEVICE}2 ${TS_MOUNTPOINT}2 +$TS_CMD_EJECT ${DEVICE}1 && ts_log "Success" +deinit_device +ts_finalize_subtest + + +ts_finalize |