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/ts/mount | |
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/ts/mount')
-rwxr-xr-x | tests/ts/mount/devname | 6 | ||||
-rwxr-xr-x | tests/ts/mount/fslists | 7 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-devname | 5 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-devname2label | 5 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-devname2uuid | 5 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-label | 5 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-label2devname | 5 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-label2uuid | 5 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-symlink | 5 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-uuid | 5 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-uuid2devname | 5 | ||||
-rwxr-xr-x | tests/ts/mount/fstab-uuid2label | 5 | ||||
-rwxr-xr-x | tests/ts/mount/label | 6 | ||||
-rwxr-xr-x | tests/ts/mount/remount | 6 | ||||
-rwxr-xr-x | tests/ts/mount/rlimit | 6 | ||||
-rwxr-xr-x | tests/ts/mount/shared-subtree | 5 | ||||
-rwxr-xr-x | tests/ts/mount/uuid | 6 |
17 files changed, 34 insertions, 58 deletions
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 |