From: Ruediger Meier Date: Tue, 31 Mar 2015 12:19:40 +0000 (+0200) Subject: tests: introduce TS_LOOP_DEVS for cleanup X-Git-Tag: v2.27-rc1~258^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cbae7931c85d232269d45ec6766b293c40cbdb09;p=thirdparty%2Futil-linux.git 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 --- diff --git a/tests/functions.sh b/tests/functions.sh index 77cc65b07e..2679a3fb0f 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 8776c67709..a1c899547a 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 e2359619b2..e8b92320e2 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 611ead3b74..bd5f628a9a 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 7c7d690efa..a5a3bf565c 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 21037170e9..19506ea885 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 < $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 cba7c311b6..f64d83cfe8 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 86230f77ce..8972037412 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 ee6b671abb..94df49e945 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 944e8af553..3596aa8e1b 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 4efd7fe062..f91419503d 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 2751cd97a0..2460a45e20 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 773cb30c84..2013a10eb7 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 272b66ec68..e9ce432e7d 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 3f29a89151..11a58e07ac 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 23cdb8fdaa..4b6bd5efc4 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 dfb97d15df..a457687552 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 789eda4a07..ccb941653e 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 3b2c4792b9..b2654a7b45 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 d275f41494..d81f48a2b5 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 79c2c8754e..19dbb06500 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 6814e313ee..95d5e8d4b1 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 2eaeb501be..f75a91ed41 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 efce11a102..f7b4b69ece 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 df1597d530..fe6c377b95 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 934455df35..59d8e1ec09 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 8296951ec7..1e6a7ccc1e 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 c1b4cb6c22..0564459462 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 329b1af080..488531ab7a 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 2ea4931841..b01d9b17b1 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