summaryrefslogtreecommitdiffstats
path: root/tests/ts/wipefs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:34 +0000
commit1272be04be0cb803eec87f602edb2e3e6f111aea (patch)
treebce17f6478cdd9f3c4ec3d751135dc42786d6a56 /tests/ts/wipefs
parentReleasing progress-linux version 2.39.3-11~progress7.99u1. (diff)
downloadutil-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.tar.xz
util-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.zip
Merging upstream version 2.40.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts/wipefs')
-rw-r--r--tests/ts/wipefs/images/bcachefs.img.xzbin0 -> 5312 bytes
-rwxr-xr-xtests/ts/wipefs/signatures40
-rwxr-xr-xtests/ts/wipefs/wipefs18
3 files changed, 50 insertions, 8 deletions
diff --git a/tests/ts/wipefs/images/bcachefs.img.xz b/tests/ts/wipefs/images/bcachefs.img.xz
new file mode 100644
index 0000000..2c74b96
--- /dev/null
+++ b/tests/ts/wipefs/images/bcachefs.img.xz
Binary files differ
diff --git a/tests/ts/wipefs/signatures b/tests/ts/wipefs/signatures
new file mode 100755
index 0000000..7749588
--- /dev/null
+++ b/tests/ts/wipefs/signatures
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2023 Thomas Weißschuh <thomas@t-8ch.de>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="signatures"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_WIPEFS"
+ts_check_prog "xz"
+
+mkdir -p "${TS_OUTDIR}/images"
+
+for img in $(ls "${TS_SELF}"/images/*.img.xz | sort); do
+ name="$(basename "$img" .img.xz)"
+ outimg="${TS_OUTDIR}/images/${name}.img"
+
+ xz -dc "$img" > "$outimg"
+
+ ts_init_subtest "$name"
+ "$TS_CMD_WIPEFS" --parsable --no-act "$outimg" 2> "$TS_ERRLOG" > "$TS_OUTPUT"
+ ts_finalize_subtest
+done
+
+ts_finalize
diff --git a/tests/ts/wipefs/wipefs b/tests/ts/wipefs/wipefs
index c79be0c..0f0f8d8 100755
--- a/tests/ts/wipefs/wipefs
+++ b/tests/ts/wipefs/wipefs
@@ -7,25 +7,27 @@ TS_DESC="wipefs"
ts_init "$*"
ts_check_test_command "$TS_CMD_WIPEFS"
+ts_check_test_command "$TS_CMD_MKMINIX"
-ts_skip_nonroot
+img="$(ts_image_init 50)"
+backups="$TS_OUTDIR/backups"
-# set global variable TS_DEVICE
-ts_scsi_debug_init dev_size_mb=50 num_parts=2
+"$TS_CMD_MKMINIX" "$img" &>/dev/null
# remove old backups
-rm -rf $HOME/wipefs-$(basename ${TS_DEVICE})-*.bak
+rm -rf "$backups"
+mkdir -p "$backups"
#remove the magic byte, back it up
-$TS_CMD_WIPEFS --all --backup ${TS_DEVICE} &>/dev/null || ts_die "wipefs failed"
+$TS_CMD_WIPEFS --all --backup="${backups}" ${img} &>/dev/null || ts_die "wipefs failed"
#there should be just one magic string/backup file in this case
-INFILE=$(ls $HOME/wipefs-$(basename ${TS_DEVICE})-*.bak)
+INFILE=$(ls $backups/wipefs-$(basename ${img})-*.bak)
OFFT=$(echo $INFILE | sed 's/^.*-\(.*\).bak$/\1/')
-dd if=$INFILE of=$TS_DEVICE bs=1 conv=notrunc seek=$(($OFFT)) &>/dev/null
+dd if=$INFILE of=$img bs=1 conv=notrunc seek=$(($OFFT)) &>/dev/null
#the bytes should be copied back, check if wipefs can recognize it
-$TS_CMD_WIPEFS -a ${TS_DEVICE} > $TS_OUTDIR/out 2>/dev/null
+$TS_CMD_WIPEFS -a ${img} > $TS_OUTDIR/out 2>/dev/null
# check for output
[ -s $TS_OUTDIR/out ] && echo "OK" &> $TS_OUTPUT || exit 1