summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOndrej Oprala2013-04-10 18:21:27 +0200
committerKarel Zak2013-04-26 12:27:37 +0200
commit7e658c15a2c1fc5092a790afbe7d9d395d04b098 (patch)
tree3b0bd40615c460fd413d912469972e4a0619305c /tests
parenttests: partx tests cleanup (diff)
downloadkernel-qcow2-util-linux-7e658c15a2c1fc5092a790afbe7d9d395d04b098.tar.gz
kernel-qcow2-util-linux-7e658c15a2c1fc5092a790afbe7d9d395d04b098.tar.xz
kernel-qcow2-util-linux-7e658c15a2c1fc5092a790afbe7d9d395d04b098.zip
wipefs: add --backup
[kzak@redhat.com: - don't wipe if failed to create a backup file - use ts_scsi_debug_init in the regression tests] Signed-off-by: Ondrej Oprala <ooprala@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/commands.sh1
-rw-r--r--tests/expected/wipefs/wipefs1
-rwxr-xr-xtests/ts/wipefs/wipefs30
3 files changed, 32 insertions, 0 deletions
diff --git a/tests/commands.sh b/tests/commands.sh
index 02ca6c3db..d12c0097c 100644
--- a/tests/commands.sh
+++ b/tests/commands.sh
@@ -66,3 +66,4 @@ TS_CMD_UL=${TS_CMD_UL-"$top_builddir/ul"}
TS_CMD_UMOUNT=${TS_CMD_UMOUNT:-"$top_builddir/umount"}
TS_CMD_UTMPDUMP=${TS_CMD_UTMPDUMP-"$top_builddir/utmpdump"}
TS_CMD_WHEREIS=${TS_CMD_WHEREIS-"$top_builddir/whereis"}
+TS_CMD_WIPEFS=${TS_CMD_WIPEFS-"$top_builddir/wipefs"}
diff --git a/tests/expected/wipefs/wipefs b/tests/expected/wipefs/wipefs
new file mode 100644
index 000000000..d86bac9de
--- /dev/null
+++ b/tests/expected/wipefs/wipefs
@@ -0,0 +1 @@
+OK
diff --git a/tests/ts/wipefs/wipefs b/tests/ts/wipefs/wipefs
new file mode 100755
index 000000000..38dbedbb1
--- /dev/null
+++ b/tests/ts/wipefs/wipefs
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+TS_TOPDIR="$(dirname $0)/../.."
+TS_DESC="wipefs"
+
+. $TS_TOPDIR/functions.sh
+ts_skip_nonroot
+ts_init "$*"
+
+DEVICE=$(ts_scsi_debug_init dev_size_mb=50 num_parts=2)
+
+# remove old backups
+rm -rf $HOME/wipefs-$(basename ${DEVICE})-*.bak
+
+#remove the magic byte, back it up
+$TS_CMD_WIPEFS --all --backup ${DEVICE} &>/dev/null || ts_die "wipefs failed"
+
+#there should be just one magic string/backup file in this case
+INFILE=$(ls $HOME/wipefs-$(basename ${DEVICE})-*.bak)
+OFFT=$(echo $INFILE | sed -E 's/^.*-(.*).bak$/\1/')
+dd if=$INFILE of=$DEVICE bs=1 conv=notrunc seek=$(($OFFT)) &>/dev/null
+
+#the bytes should be copied back, check if wipefs can recognize it
+$TS_CMD_WIPEFS -a ${DEVICE} > $TS_OUTDIR/out 2>/dev/null
+
+# check for output
+[ -s $TS_OUTDIR/out ] && echo "OK" &> $TS_OUTPUT || exit 1
+
+rmmod scsi_debug &>/dev/null
+ts_finalize