]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
wipefs: (tests) remove necessity of root permissions
authorThomas Weißschuh <thomas@t-8ch.de>
Sun, 31 Dec 2023 13:00:18 +0000 (14:00 +0100)
committerThomas Weißschuh <thomas@t-8ch.de>
Tue, 2 Jan 2024 10:37:39 +0000 (11:37 +0100)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
tests/ts/wipefs/wipefs

index c79be0cc6d7c6b32e2a6397a1b923021f7908622..e96f3717f078dea12be5bee609f145f7ed1a861c 100755 (executable)
@@ -7,25 +7,25 @@ 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)"
 
-# 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 $HOME/wipefs-$(basename ${img})-*.bak
 
 #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 ${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 $HOME/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