diff options
author | Karel Zak | 2012-04-05 15:58:02 +0200 |
---|---|---|
committer | Karel Zak | 2012-04-05 15:58:28 +0200 |
commit | 4f469e588df4f2867bd575a4c899135a9a41e9c4 (patch) | |
tree | 38315dc405e5730b125778b7991d73f114416c57 /tests | |
parent | lsblk: count with terminating character, man page -s entry (diff) | |
parent | tests: use eject --force (diff) | |
download | kernel-qcow2-util-linux-4f469e588df4f2867bd575a4c899135a9a41e9c4.tar.gz kernel-qcow2-util-linux-4f469e588df4f2867bd575a4c899135a9a41e9c4.tar.xz kernel-qcow2-util-linux-4f469e588df4f2867bd575a4c899135a9a41e9c4.zip |
Merge branch 'eject'
* eject: (47 commits)
tests: use eject --force
eject: use BUILD_EJECT, move to sys-utils
eject: clean up usage()
eject: clean up man page
eject: add --force option
eject: check for hotplug/removable attribute
eject: remove obsolete code, use EXIT_* macros
tests: add umount-by-eject tests
eject: improve work with partitioned devices
lib/sysfs: improve sysfs_is_partition_dirent()
eject: call umount <mountpoint> rather than <device>
eject: use libmount to detect if cdrom is mounted
eject: make the code robust
eject: use SG_IO ioctl for scsi
eject: support CDIOCEJECT ioctl
eject: new close_tray code from Fedora
eject: new auto_eject code from Fedora
eject: add -X from Fedora
eject: add --manualeject from fedora
eject: clean up devname usage
...
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 | 111 |
8 files changed, 120 insertions, 0 deletions
diff --git a/tests/commands.sh.in b/tests/commands.sh.in index 1ce112a52..b01ebc729 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/sys-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 000000000..e69de29bb --- /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 000000000..35821117c --- /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 000000000..35821117c --- /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 000000000..2a99ba0b4 --- /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 000000000..2a99ba0b4 --- /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 000000000..2a99ba0b4 --- /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 000000000..3081c1f18 --- /dev/null +++ b/tests/ts/eject/umount @@ -0,0 +1,111 @@ +#!/bin/bash + +TS_TOPDIR="$(dirname $0)/../.." +TS_DESC="umount" + +. $TS_TOPDIR/functions.sh +ts_init "$*" +ts_skip_nonroot + +# +# Note that eject --force is required because scsi_debug is +# not removable device. +# + +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 --force $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 --force $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 --force $DEVICE && ts_log "Success" +deinit_device +ts_finalize_subtest + + +ts_init_subtest "by-partition" +DEVICE=$(init_device) +init_partitions $DEVICE +$TS_CMD_EJECT --force ${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 --force ${DEVICE}1 && ts_log "Success" +deinit_device +ts_finalize_subtest + + +ts_finalize |