summaryrefslogtreecommitdiffstats
path: root/tests/ts/swapon
diff options
context:
space:
mode:
authorRuediger Meier2015-03-31 14:19:40 +0200
committerRuediger Meier2015-04-14 13:18:42 +0200
commitcbae7931c85d232269d45ec6766b293c40cbdb09 (patch)
treeb87f66967928f66a9ab8787a5b13c526a5d53024 /tests/ts/swapon
parenttests: introduce ts_cleanup_on_exit() (diff)
downloadkernel-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/swapon')
-rwxr-xr-xtests/ts/swapon/devname5
-rwxr-xr-xtests/ts/swapon/fixpgsz4
-rwxr-xr-xtests/ts/swapon/fixsig5
-rwxr-xr-xtests/ts/swapon/label5
-rwxr-xr-xtests/ts/swapon/uuid5
5 files changed, 10 insertions, 14 deletions
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