diff options
author | Ruediger Meier | 2015-03-31 14:19:40 +0200 |
---|---|---|
committer | Ruediger Meier | 2015-04-14 13:18:42 +0200 |
commit | cbae7931c85d232269d45ec6766b293c40cbdb09 (patch) | |
tree | b87f66967928f66a9ab8787a5b13c526a5d53024 /tests | |
parent | tests: introduce ts_cleanup_on_exit() (diff) | |
download | kernel-qcow2-util-linux-cbae7931c85d232269d45ec6766b293c40cbdb09.tar.gz kernel-qcow2-util-linux-cbae7931c85d232269d45ec6766b293c40cbdb09.tar.xz kernel-qcow2-util-linux-cbae7931c85d232269d45ec6766b293c40cbdb09.zip |
tests: introduce TS_LOOP_DEVS for cleanup
We are maintaining an array TS_LOOP_DEVS to de-initialize devices
always on exit. Until now there was no cleanup in ts_skip().
The downside is that we can't execute ts_device_init() in a subshell
anymore. The device is returned via global variable TS_LODEV, similar
like we do already in ts_scsi_debug_init().
Tests which don't use ts_device_init() to create loop devices may use
ts_register_loop_device() to get them cleaned up later.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'tests')
31 files changed, 80 insertions, 105 deletions
diff --git a/tests/functions.sh b/tests/functions.sh index 77cc65b07..2679a3fb0 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -86,9 +86,7 @@ function ts_skip_subtest { function ts_skip { ts_skip_subtest "$1" - if [ -n "$2" -a -b "$2" ]; then - ts_device_deinit "$2" - fi + ts_cleanup_on_exit exit 0 } @@ -254,6 +252,7 @@ function ts_init_env { declare -a TS_SUID_PROGS declare -a TS_SUID_USER declare -a TS_SUID_GROUP + declare -a TS_LOOP_DEVS if [ -f $TS_TOPDIR/commands.sh ]; then . $TS_TOPDIR/commands.sh @@ -436,10 +435,6 @@ function ts_finalize { function ts_die { ts_log "$1" - if [ -n "$2" ] && [ -b "$2" ]; then - ts_device_deinit "$2" - ts_fstab_clean # for sure... - fi ts_finalize } @@ -450,6 +445,11 @@ function ts_cleanup_on_exit { chmod a-s $PROG &> /dev/null chown ${TS_SUID_USER[$idx]}.${TS_SUID_GROUP[$idx]} $PROG &> /dev/null done + + for dev in "${TS_LOOP_DEVS[@]}"; do + ts_device_deinit "$dev" + done + unset TS_LOOP_DEVS } function ts_image_md5sum { @@ -466,16 +466,26 @@ function ts_image_init { return 0 } +function ts_register_loop_device { + local ct=${#TS_LOOP_DEVS[*]} + TS_LOOP_DEVS[$ct]=$1 +} + function ts_device_init { local img local dev img=$(ts_image_init $1 $2) dev=$($TS_CMD_LOSETUP --show -f "$img") + if [ "$?" != "0" -o "$dev" = "" ]; then + ts_die "Cannot init device" + fi - echo $dev + ts_register_loop_device "$dev" + TS_LODEV=$dev } +# call from ts_cleanup_on_exit() only because of TS_LOOP_DEVS maintenance function ts_device_deinit { local DEV="$1" diff --git a/tests/ts/blkdiscard/offsets b/tests/ts/blkdiscard/offsets index 8776c6770..a1c899547 100755 --- a/tests/ts/blkdiscard/offsets +++ b/tests/ts/blkdiscard/offsets @@ -36,6 +36,7 @@ truncate -s 10M $IMAGE_PATH ts_log "create loop device from image" DEVICE=$($TS_CMD_LOSETUP --show -f $IMAGE_PATH) +ts_register_loop_device "$DEVICE" CMD_SED_DEVICE="sed s#$DEVICE:\s##" ts_log "testing offsets with full block size" @@ -82,7 +83,6 @@ $TS_CMD_BLKDISCARD -v -p 511 -o 1 -l 10240 $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS $TS_CMD_BLKDISCARD -v -p 511 -o 511 -l 10240 $DEVICE 2>&1 | $CMD_SED_DEVICE >> $TS_OUTPUT ts_log "detach loop device from image" -$TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT ts_cd "$ORIGPWD" diff --git a/tests/ts/blkid/md-raid0-whole b/tests/ts/blkid/md-raid0-whole index e2359619b..e8b92320e 100755 --- a/tests/ts/blkid/md-raid0-whole +++ b/tests/ts/blkid/md-raid0-whole @@ -34,11 +34,11 @@ set -o pipefail ts_log "Initialize devices" IMGNAME="${TS_OUTDIR}/${TS_TESTNAME}" -DEVICE1=$(ts_device_init 50 ${IMGNAME}1.img) -[ "$?" == 0 ] || ts_die "Cannot init device1" +ts_device_init 50 ${IMGNAME}1.img +DEVICE1=$TS_LODEV -DEVICE2=$(ts_device_init 50 ${IMGNAME}2.img) -[ "$?" == 0 ] || ts_die "Cannot init device2" $DEVICE1 +ts_device_init 50 ${IMGNAME}2.img +DEVICE2=$TS_LODEV MD_DEVNAME=md8 MD_DEVICE=/dev/${MD_DEVNAME} @@ -80,8 +80,6 @@ mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>&1 udevadm settle ts_log "Deinitialize devices" -ts_device_deinit $DEVICE1 -ts_device_deinit $DEVICE2 ts_fdisk_clean $MD_DEVICE diff --git a/tests/ts/blkid/md-raid1-whole b/tests/ts/blkid/md-raid1-whole index 611ead3b7..bd5f628a9 100755 --- a/tests/ts/blkid/md-raid1-whole +++ b/tests/ts/blkid/md-raid1-whole @@ -34,11 +34,11 @@ set -o pipefail ts_log "Initialize devices" IMGNAME="${TS_OUTDIR}/${TS_TESTNAME}" -DEVICE1=$(ts_device_init 50 ${IMGNAME}1.img) -[ "$?" == 0 ] || ts_die "Cannot init device1" +ts_device_init 50 ${IMGNAME}1.img +DEVICE1=$TS_LODEV -DEVICE2=$(ts_device_init 50 ${IMGNAME}2.img) -[ "$?" == 0 ] || ts_die "Cannot init device2" $DEVICE1 +ts_device_init 50 ${IMGNAME}2.img +DEVICE2=$TS_LODEV MD_DEVNAME=md8 MD_DEVICE=/dev/${MD_DEVNAME} @@ -80,8 +80,6 @@ mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>&1 udevadm settle ts_log "Deinitialize devices" -ts_device_deinit $DEVICE1 -ts_device_deinit $DEVICE2 ts_fdisk_clean # remove generated UUIDs diff --git a/tests/ts/cramfs/mkfs b/tests/ts/cramfs/mkfs index 7c7d690ef..a5a3bf565 100755 --- a/tests/ts/cramfs/mkfs +++ b/tests/ts/cramfs/mkfs @@ -86,6 +86,7 @@ echo >> $TS_OUTPUT ts_log "create loop device from image" DEVICE=$($TS_CMD_LOSETUP --show -f $IMAGE_PATH) +ts_register_loop_device "$DEVICE" ts_log "check the image" ts_device_has "TYPE" "cramfs" $DEVICE @@ -111,7 +112,5 @@ echo >> $TS_OUTPUT ts_cd "$ORIGPWD" ts_log "umount the image" -$TS_CMD_UMOUNT $DEVICE -$TS_CMD_LOSETUP -d $DEVICE 2>&1 >> $TS_OUTPUT ts_finalize diff --git a/tests/ts/fdisk/align-512-512 b/tests/ts/fdisk/align-512-512 index 21037170e..19506ea88 100755 --- a/tests/ts/fdisk/align-512-512 +++ b/tests/ts/fdisk/align-512-512 @@ -30,8 +30,8 @@ ts_check_test_command "$TS_CMD_FDISK" ts_skip_nonroot ts_check_losetup -DEVICE=$(ts_device_init 50) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init 50 +DEVICE=$TS_LODEV ts_log "Create partitions" $TS_CMD_FDISK ${DEVICE} >> $TS_OUTPUT 2>&1 <<EOF @@ -67,7 +67,6 @@ p q EOF -ts_device_deinit $DEVICE ts_fdisk_clean $DEVICE ts_finalize diff --git a/tests/ts/fsck/ismounted b/tests/ts/fsck/ismounted index bff0b8114..e4f0b4d30 100755 --- a/tests/ts/fsck/ismounted +++ b/tests/ts/fsck/ismounted @@ -31,8 +31,8 @@ set -o pipefail > $TS_OUTPUT -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -47,5 +47,4 @@ $TS_HELPER_ISMOUNTED $DEVICE | awk '{print $1}' >> $TS_OUTPUT 2>&1 $TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" $DEVICE -ts_device_deinit $DEVICE ts_finalize diff --git a/tests/ts/minix/fsck b/tests/ts/minix/fsck index cba7c311b..f64d83cfe 100755 --- a/tests/ts/minix/fsck +++ b/tests/ts/minix/fsck @@ -28,7 +28,8 @@ ts_check_losetup set -o pipefail IMAGE="$TS_OUTDIR/${TS_TESTNAME}-loop.img" -DEVICE=$(ts_device_init) +ts_device_init +DEVICE=$TS_LODEV ts_log "create minix fs" $TS_CMD_MKMINIX $DEVICE 2>&1 >> $TS_OUTPUT @@ -36,6 +37,5 @@ $TS_CMD_MKMINIX $DEVICE 2>&1 >> $TS_OUTPUT ts_log "fsck minix fs" $TS_CMD_FSCKMINIX $DEVICE 2>&1 >> $TS_OUTPUT -ts_device_deinit $DEVICE ts_finalize diff --git a/tests/ts/minix/mkfs b/tests/ts/minix/mkfs index 86230f77c..897203741 100755 --- a/tests/ts/minix/mkfs +++ b/tests/ts/minix/mkfs @@ -28,7 +28,8 @@ ts_check_losetup set -o pipefail IMAGE="$TS_OUTDIR/${TS_TESTNAME}-loop.img" -DEVICE=$(ts_device_init) +ts_device_init +DEVICE=$TS_LODEV ts_log "create minix fs" $TS_CMD_MKMINIX $DEVICE 2>&1 >> $TS_OUTPUT @@ -44,6 +45,5 @@ ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" $DEVICE ts_log "umount the image" $TS_CMD_UMOUNT $DEVICE -ts_device_deinit $DEVICE ts_finalize diff --git a/tests/ts/mount/devname b/tests/ts/mount/devname index ee6b671ab..94df49e94 100755 --- a/tests/ts/mount/devname +++ b/tests/ts/mount/devname @@ -31,8 +31,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -52,8 +52,6 @@ $TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" $DEVICE grep -q $DEVICE /etc/mtab && echo "umount failed: found $DEVICE in mtab" >> $TS_OUTPUT 2>&1 -ts_device_deinit $DEVICE - ts_log "Success" ts_finalize diff --git a/tests/ts/mount/fslists b/tests/ts/mount/fslists index 944e8af55..3596aa8e1 100755 --- a/tests/ts/mount/fslists +++ b/tests/ts/mount/fslists @@ -31,8 +31,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -87,9 +87,6 @@ ts_is_mounted $DEVICE && ts_die "$DEVICE unexpectedly mounted" $DEVICE ts_log "Success" ts_finalize_subtest - -ts_device_deinit $DEVICE - ts_log "Success" ts_finalize diff --git a/tests/ts/mount/fstab-devname b/tests/ts/mount/fstab-devname index 4efd7fe06..f91419503 100755 --- a/tests/ts/mount/fstab-devname +++ b/tests/ts/mount/fstab-devname @@ -30,8 +30,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -51,7 +51,6 @@ $TS_CMD_MOUNT $DEVICE 2>&1 >> $TS_OUTPUT ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE -ts_device_deinit $DEVICE ts_fstab_clean ts_log "Success" diff --git a/tests/ts/mount/fstab-devname2label b/tests/ts/mount/fstab-devname2label index 2751cd97a..2460a45e2 100755 --- a/tests/ts/mount/fstab-devname2label +++ b/tests/ts/mount/fstab-devname2label @@ -31,8 +31,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -47,7 +47,6 @@ $TS_CMD_MOUNT $DEVICE 2>&1 >> $TS_OUTPUT ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" $DEVICE -ts_device_deinit $DEVICE ts_fstab_clean ts_log "Success" diff --git a/tests/ts/mount/fstab-devname2uuid b/tests/ts/mount/fstab-devname2uuid index 773cb30c8..2013a10eb 100755 --- a/tests/ts/mount/fstab-devname2uuid +++ b/tests/ts/mount/fstab-devname2uuid @@ -30,8 +30,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -47,7 +47,6 @@ $TS_CMD_MOUNT $DEVICE 2>&1 >> $TS_OUTPUT ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE" $DEVICE -ts_device_deinit $DEVICE ts_fstab_clean ts_log "Success" diff --git a/tests/ts/mount/fstab-label b/tests/ts/mount/fstab-label index 272b66ec6..e9ce432e7 100755 --- a/tests/ts/mount/fstab-label +++ b/tests/ts/mount/fstab-label @@ -31,8 +31,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -58,7 +58,6 @@ $TS_CMD_MOUNT LABEL=$LABEL 2>&1 >> $TS_OUTPUT ts_is_mounted $DEVICE || ts_die "C) Cannot find $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "C) Cannot umount $DEVICE" $DEVICE -ts_device_deinit $DEVICE ts_fstab_clean ts_log "Success" diff --git a/tests/ts/mount/fstab-label2devname b/tests/ts/mount/fstab-label2devname index 3f29a8915..11a58e07a 100755 --- a/tests/ts/mount/fstab-label2devname +++ b/tests/ts/mount/fstab-label2devname @@ -31,8 +31,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -53,7 +53,6 @@ $TS_CMD_MOUNT "LABEL=$LABEL" 2>&1 >> $TS_OUTPUT ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE -ts_device_deinit $DEVICE ts_fstab_clean ts_log "Success" diff --git a/tests/ts/mount/fstab-label2uuid b/tests/ts/mount/fstab-label2uuid index 23cdb8fda..4b6bd5efc 100755 --- a/tests/ts/mount/fstab-label2uuid +++ b/tests/ts/mount/fstab-label2uuid @@ -32,8 +32,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -58,7 +58,6 @@ $TS_CMD_MOUNT "LABEL=$LABEL" 2>&1 >> $TS_OUTPUT ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE -ts_device_deinit $DEVICE ts_fstab_clean ts_log "Success" diff --git a/tests/ts/mount/fstab-symlink b/tests/ts/mount/fstab-symlink index dfb97d15d..a45768755 100755 --- a/tests/ts/mount/fstab-symlink +++ b/tests/ts/mount/fstab-symlink @@ -33,8 +33,8 @@ set -o pipefail LINKNAME="$TS_OUTDIR/${TS_TESTNAME}_lnk" -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -65,7 +65,6 @@ $TS_CMD_UMOUNT $LINKNAME || ts_die "A) Cannot umount $LINKNAME" $DEVICE #su $TS_TESTUSER -c "$TS_CMD_UMOUNT $LINKNAME" 2>&1 >> $TS_OUTPUT \ # || ts_die "B) Cannot umount $LINKNAME" $DEVICE -ts_device_deinit $DEVICE ts_fstab_clean rm -f $LINKNAME diff --git a/tests/ts/mount/fstab-uuid b/tests/ts/mount/fstab-uuid index 789eda4a0..ccb941653 100755 --- a/tests/ts/mount/fstab-uuid +++ b/tests/ts/mount/fstab-uuid @@ -30,8 +30,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -58,7 +58,6 @@ $TS_CMD_MOUNT UUID=$UUID 2>&1 >> $TS_OUTPUT ts_is_mounted $DEVICE || ts_die "C) Cannot find $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "C) Cannot umount $DEVICE" $DEVICE -ts_device_deinit $DEVICE ts_fstab_clean ts_log "Success" diff --git a/tests/ts/mount/fstab-uuid2devname b/tests/ts/mount/fstab-uuid2devname index 3b2c4792b..b2654a7b4 100755 --- a/tests/ts/mount/fstab-uuid2devname +++ b/tests/ts/mount/fstab-uuid2devname @@ -30,8 +30,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -53,7 +53,6 @@ $TS_CMD_MOUNT "UUID=$UUID" 2>&1 >> $TS_OUTPUT ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE -ts_device_deinit $DEVICE ts_fstab_clean ts_log "Success" diff --git a/tests/ts/mount/fstab-uuid2label b/tests/ts/mount/fstab-uuid2label index d275f4149..d81f48a2b 100755 --- a/tests/ts/mount/fstab-uuid2label +++ b/tests/ts/mount/fstab-uuid2label @@ -31,8 +31,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -57,7 +57,6 @@ $TS_CMD_MOUNT "UUID=$UUID" 2>&1 >> $TS_OUTPUT ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE -ts_device_deinit $DEVICE ts_fstab_clean ts_log "Success" diff --git a/tests/ts/mount/label b/tests/ts/mount/label index 79c2c8754..19dbb0650 100755 --- a/tests/ts/mount/label +++ b/tests/ts/mount/label @@ -32,8 +32,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 -L $LABEL $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -52,8 +52,6 @@ $TS_CMD_MOUNT LABEL=$LABEL $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE -ts_device_deinit $DEVICE - ts_log "Success" ts_finalize diff --git a/tests/ts/mount/remount b/tests/ts/mount/remount index 6814e313e..95d5e8d4b 100755 --- a/tests/ts/mount/remount +++ b/tests/ts/mount/remount @@ -31,8 +31,8 @@ ts_check_losetup # mountpoint [ -d $TS_MOUNTPOINT ] || mkdir -p $TS_MOUNTPOINT -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext2 $DEVICE &> /dev/null || ts_die "Cannot make ext2 on $DEVICE" $DEVICE @@ -51,8 +51,6 @@ $TS_CMD_MOUNT -o remount,ro $TS_MOUNTPOINT \ $TS_CMD_FINDMNT --kernel --mountpoint "$TS_MOUNTPOINT" --options "ro" &> /dev/null [ "$?" == "0" ] || ts_die "Cannot find read-only in $TS_MOUNTPOINT in /proc/self/mountinfo" -ts_device_deinit $DEVICE - ts_log "Success" ts_finalize diff --git a/tests/ts/mount/rlimit b/tests/ts/mount/rlimit index 2eaeb501b..f75a91ed4 100755 --- a/tests/ts/mount/rlimit +++ b/tests/ts/mount/rlimit @@ -46,8 +46,8 @@ function mtab_checksum() md5sum /etc/mtab | awk '{printf $1}' } -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -87,7 +87,5 @@ else fi ts_finalize_subtest - -ts_device_deinit $DEVICE ts_log "Success" ts_finalize diff --git a/tests/ts/mount/shared-subtree b/tests/ts/mount/shared-subtree index efce11a10..f7b4b69ec 100755 --- a/tests/ts/mount/shared-subtree +++ b/tests/ts/mount/shared-subtree @@ -59,8 +59,8 @@ ts_finalize_subtest # # block dev based mounts # -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE ts_device_has "TYPE" "ext3" $DEVICE || ts_die "Cannot find ext3 on $DEVICE" $DEVICE @@ -80,7 +80,6 @@ $TS_CMD_FINDMNT -nr --mountpoint $MOUNTPOINT -o VFS-OPTIONS >> $TS_OUTPUT $TS_CMD_UMOUNT $MOUNTPOINT ts_finalize_subtest -ts_device_deinit $DEVICE rmdir $MOUNTPOINT ts_log "Success" diff --git a/tests/ts/mount/uuid b/tests/ts/mount/uuid index df1597d53..fe6c377b9 100755 --- a/tests/ts/mount/uuid +++ b/tests/ts/mount/uuid @@ -30,8 +30,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV mkfs.ext3 $DEVICE &> /dev/null || ts_die "Cannot make ext3 on $DEVICE" $DEVICE @@ -51,8 +51,6 @@ $TS_CMD_MOUNT UUID=$UUID $TS_MOUNTPOINT 2>&1 >> $TS_OUTPUT ts_is_mounted $DEVICE || ts_die "B) Cannot find $DEVICE in /proc/mounts" $DEVICE $TS_CMD_UMOUNT $DEVICE || ts_die "B) Cannot umount $DEVICE" $DEVICE -ts_device_deinit $DEVICE - ts_log "Success" ts_finalize diff --git a/tests/ts/swapon/devname b/tests/ts/swapon/devname index 934455df3..59d8e1ec0 100755 --- a/tests/ts/swapon/devname +++ b/tests/ts/swapon/devname @@ -30,8 +30,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV $TS_CMD_MKSWAP $DEVICE > /dev/null 2>> $TS_OUTPUT \ || ts_die "Cannot make swap $DEVICE" $DEVICE @@ -43,7 +43,6 @@ $TS_CMD_SWAPON $DEVICE 2>&1 >> $TS_OUTPUT grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" $DEVICE $TS_CMD_SWAPOFF $DEVICE -ts_device_deinit $DEVICE ts_log "Success" ts_finalize diff --git a/tests/ts/swapon/fixpgsz b/tests/ts/swapon/fixpgsz index 8296951ec..1e6a7ccc1 100755 --- a/tests/ts/swapon/fixpgsz +++ b/tests/ts/swapon/fixpgsz @@ -28,7 +28,8 @@ else BADSIZE=4096 fi -DEVICE=$(ts_device_init) +ts_device_init +DEVICE=$TS_LODEV $TS_CMD_MKSWAP -L MyFooBarLabel --pagesize $BADSIZE $DEVICE > /dev/null &> /dev/null \ || ts_die "Cannot make swap $DEVICE" $DEVICE @@ -43,7 +44,6 @@ $TS_CMD_SWAPON --fixpgsz $DEVICE &> /dev/null grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" $DEVICE $TS_CMD_SWAPOFF $DEVICE -ts_device_deinit $DEVICE ts_log "Success" ts_finalize diff --git a/tests/ts/swapon/fixsig b/tests/ts/swapon/fixsig index c1b4cb6c2..056445946 100755 --- a/tests/ts/swapon/fixsig +++ b/tests/ts/swapon/fixsig @@ -20,8 +20,8 @@ PAGESIZE=$($TS_HELPER_SYSINFO pagesize) # # Create a swap-area # -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV $TS_CMD_MKSWAP $DEVICE > /dev/null 2>> $TS_OUTPUT \ || ts_die "Cannot make swap $DEVICE" $DEVICE @@ -45,7 +45,6 @@ $TS_CMD_SWAPON $DEVICE &> /dev/null grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" $DEVICE $TS_CMD_SWAPOFF $DEVICE -ts_device_deinit $DEVICE ts_log "Success" ts_finalize diff --git a/tests/ts/swapon/label b/tests/ts/swapon/label index 329b1af08..488531ab7 100755 --- a/tests/ts/swapon/label +++ b/tests/ts/swapon/label @@ -31,8 +31,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV $TS_CMD_MKSWAP -L $LABEL $DEVICE > /dev/null 2>> $TS_OUTPUT \ || ts_die "Cannot make swap on $DEVICE" $DEVICE @@ -45,7 +45,6 @@ $TS_CMD_SWAPON -L $LABEL 2>&1 >> $TS_OUTPUT grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" $DEVICE $TS_CMD_SWAPOFF $DEVICE -ts_device_deinit $DEVICE ts_log "Success" ts_finalize diff --git a/tests/ts/swapon/uuid b/tests/ts/swapon/uuid index 2ea493184..b01d9b17b 100755 --- a/tests/ts/swapon/uuid +++ b/tests/ts/swapon/uuid @@ -30,8 +30,8 @@ ts_check_losetup set -o pipefail -DEVICE=$(ts_device_init) -[ "$?" == 0 ] || ts_die "Cannot init device" +ts_device_init +DEVICE=$TS_LODEV $TS_CMD_MKSWAP $DEVICE > /dev/null 2>> $TS_OUTPUT \ || ts_die "Cannot make swap $DEVICE" $DEVICE @@ -45,7 +45,6 @@ $TS_CMD_SWAPON -U $UUID 2>&1 >> $TS_OUTPUT grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" $DEVICE $TS_CMD_SWAPOFF $DEVICE -ts_device_deinit $DEVICE ts_log "Success" ts_finalize |