]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: introduce TS_LOOP_DEVS for cleanup
authorRuediger Meier <ruediger.meier@ga-group.nl>
Tue, 31 Mar 2015 12:19:40 +0000 (14:19 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 29 Apr 2015 10:37:21 +0000 (12:37 +0200)
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>
31 files changed:
tests/functions.sh
tests/ts/blkdiscard/offsets
tests/ts/blkid/md-raid0-whole
tests/ts/blkid/md-raid1-whole
tests/ts/cramfs/mkfs
tests/ts/fdisk/align-512-512
tests/ts/fsck/ismounted
tests/ts/minix/fsck
tests/ts/minix/mkfs
tests/ts/mount/devname
tests/ts/mount/fslists
tests/ts/mount/fstab-devname
tests/ts/mount/fstab-devname2label
tests/ts/mount/fstab-devname2uuid
tests/ts/mount/fstab-label
tests/ts/mount/fstab-label2devname
tests/ts/mount/fstab-label2uuid
tests/ts/mount/fstab-symlink
tests/ts/mount/fstab-uuid
tests/ts/mount/fstab-uuid2devname
tests/ts/mount/fstab-uuid2label
tests/ts/mount/label
tests/ts/mount/remount
tests/ts/mount/rlimit
tests/ts/mount/shared-subtree
tests/ts/mount/uuid
tests/ts/swapon/devname
tests/ts/swapon/fixpgsz
tests/ts/swapon/fixsig
tests/ts/swapon/label
tests/ts/swapon/uuid

index 5c431eacdec65fa030cdacce78f97a856877967b..a624c3e2c3403faca24a9e227d73a371798de7f3 100644 (file)
@@ -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"
 
index 8776c67709cde67439d350ae01eaf202380f9f74..a1c899547a0186a6b8aca04f3df7130069ef1527 100755 (executable)
@@ -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"
 
index e2359619b2382f539f3da133a48328e48c14efa3..e8b92320e2a54ee7664665b2c0673aaf2733d1d1 100755 (executable)
@@ -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
 
index 611ead3b7459f652e8d2e2c57a68c13c7a840288..bd5f628a9ab038a143115ee29499f8ae0f914d4d 100755 (executable)
@@ -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
index 7c7d690efaf63bcf470509da479218714c159102..a5a3bf565cd8100442af37a281a5964e25a88a4c 100755 (executable)
@@ -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
 
index 21037170e98bc84af7e4d8bb325c41d250283fe5..19506ea88584e4a28760dd71c9f6001dee3b9b2b 100755 (executable)
@@ -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
index bff0b8114631e5d34de4ecff7069d3c81bf89a39..e4f0b4d30fa7c56c05b10875e09f3dfb91b6d238 100755 (executable)
@@ -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
index cba7c311b63804681515916c1916f3f1513d2055..f64d83cfe81d590de296690df813f0a540a076f6 100755 (executable)
@@ -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
 
index 86230f77ce31038a3d5f919de2f4ce7ec30ef7ca..89720374124137c5add47585df5ca58ea9a8c481 100755 (executable)
@@ -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
 
index ee6b671abb372e5af6eb4aa4b03d280231ec6210..94df49e94532f8a0b00b259bace248043011b4ea 100755 (executable)
@@ -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
 
index 944e8af553d9dc88879f8b40c68d3994cc0a5386..3596aa8e1b7867e8e58c707d6a1aa16993f797c0 100755 (executable)
@@ -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
 
index 4efd7fe062c047148b3919e42b419066f22cb282..f91419503d52907896a17050ffc86b9f0988c804 100755 (executable)
@@ -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"
index 2751cd97a09abf8d167a406fe0796699d97fc25b..2460a45e20127082cb3efae84060bab521a05e85 100755 (executable)
@@ -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"
index 773cb30c84dfb3f489c13b17197feb5fb8084a10..2013a10eb736609650f0a763f918c04545a0b015 100755 (executable)
@@ -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"
index 272b66ec6856e383bc4f5626b3f3169426aa226e..e9ce432e7dc936a498cd07edc03e04696e7f45b7 100755 (executable)
@@ -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"
index 3f29a8915105d322013aa3d4c4148fe9c6951e28..11a58e07acd54e652151a79f7c255a301780e1bb 100755 (executable)
@@ -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"
index 23cdb8fdaa210ebff7d45cc1624196afbbfd3654..4b6bd5efc40146758b351acfa8680a0d186bb13b 100755 (executable)
@@ -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"
index dfb97d15df526e767903cbecd56fcc593256c8b9..a4576875523bfee891bc91e44452409cbbbcdad3 100755 (executable)
@@ -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
 
index 789eda4a07ea89526c05d631788ed70fc6ed426e..ccb941653ef6629c52a6b71a0ec1cc3cd39c4c1f 100755 (executable)
@@ -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"
index 3b2c4792b9f9f2b64bd2f7a7b4299d6a42f3f502..b2654a7b45816d192e51ebdde335079387ebd51f 100755 (executable)
@@ -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"
index d275f41494337461d60b394f654ddc146b490bcc..d81f48a2b535b506586005c8c51729a11d8817d3 100755 (executable)
@@ -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"
index 79c2c8754e343bc07bd2107d805530f169487986..19dbb06500e6b44cc461525cefb88140db4263ca 100755 (executable)
@@ -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
 
index 99ede4a75c2fefabefad1a84265201a14f340b2b..2b0e05382a4029f6415d14848d503ad7b843346c 100755 (executable)
@@ -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 --target "$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
 
index 2eaeb501bee8d5cd64ea4b552a33e7e948f430d2..f75a91ed41a5cc3fa1fb557dac34d30e9f88f196 100755 (executable)
@@ -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
index 45154835d00c3e587af7badfe8d67c9f1ab9dac6..f9cb3de57de917459d1c94b8a96f10e1f63e317d 100755 (executable)
@@ -58,8 +58,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
@@ -79,7 +79,6 @@ $TS_CMD_FINDMNT -nr --target $MOUNTPOINT -o VFS-OPTIONS >> $TS_OUTPUT
 $TS_CMD_UMOUNT $MOUNTPOINT
 ts_finalize_subtest
 
-ts_device_deinit $DEVICE
 rmdir $MOUNTPOINT
 
 ts_log "Success"
index df1597d530d8fed837790e31c2c05934b181f666..fe6c377b951eb9751e46a36433ebea7153ea6ac9 100755 (executable)
@@ -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
 
index 934455df3514e556c78851c96d1724fd8411a913..59d8e1ec091f9abbf280a28d80e0a5c75597e9bf 100755 (executable)
@@ -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
index 8296951ec77b536d76a27e0f3a9591d18c5f0989..1e6a7ccc1ec00f420ee3fc71249f0d2022109d9a 100755 (executable)
@@ -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
index c1b4cb6c22d8bc37e7d97c1013997e1ac8752004..05644594628e391cb3072ab246e5d7b892e560ab 100755 (executable)
@@ -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
index 329b1af0802ce1f3454b70774c21646050b53e3d..488531ab7a6dd7362049da8f63025446b16c6556 100755 (executable)
@@ -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
index 2ea4931841a15574c6924cfdb8fb876202ff54d0..b01d9b17b18447af5e45e35326b5ba1df0738034 100755 (executable)
@@ -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