Unify use of tabulators in tests.

This commit is contained in:
Milan Broz
2022-07-16 18:49:39 +02:00
parent 8f3884e0d7
commit 648a85ed3a
6 changed files with 100 additions and 100 deletions

View File

@@ -13,8 +13,8 @@ FAST_PBKDF="--pbkdf-force-iterations 1000"
cleanup() {
udevadm settle >/dev/null 2>&1
if [ -d "$MNT_DIR" ] ; then
umount -f $MNT_DIR 2>/dev/null
rmdir $MNT_DIR 2>/dev/null
umount -f $MNT_DIR 2>/dev/null
rmdir $MNT_DIR 2>/dev/null
fi
[ -b /dev/mapper/$DEV_STACKED ] && dmsetup remove --retry $DEV_STACKED >/dev/null 2>&1
[ -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME >/dev/null 2>&1

View File

@@ -14,8 +14,8 @@ FAST_PBKDF="--pbkdf pbkdf2 --pbkdf-force-iterations 1000"
cleanup() {
udevadm settle >/dev/null 2>&1
if [ -d "$MNT_DIR" ] ; then
umount -f $MNT_DIR 2>/dev/null
rmdir $MNT_DIR 2>/dev/null
umount -f $MNT_DIR 2>/dev/null
rmdir $MNT_DIR 2>/dev/null
fi
[ -b /dev/mapper/$DEV_STACKED ] && dmsetup remove --retry $DEV_STACKED >/dev/null 2>&1
[ -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME >/dev/null 2>&1

View File

@@ -80,24 +80,24 @@ falloc() {
run_all_in_fs() {
for file in $(ls img_fs_*.img.xz) ; do
echo "Run tests in $file put on top block device."
xz -d -c $file | dd of=$DEV bs=1M 2>/dev/null || fail "bad image"
[ ! -d $MNT_DIR ] && mkdir $MNT_DIR
mount $DEV $MNT_DIR
if [ $? -ne 0 ]; then
echo "Mounting image $file failed, skipped."
continue;
fi
rm -rf $MNT_DIR/* 2>/dev/null
local tfile=$MNT_DIR/bwunit_tstfile
falloc $DEVSIZEMB $tfile || fail "enospc?"
local iobsize=$(stat -c "%o" $tfile)
test -n "$iobsize" -a $iobsize -gt 0 || fail
local oldbsize=$BSIZE
BSIZE=$iobsize
run_all $tfile
BSIZE=$oldbsize
umount $MNT_DIR
echo "Run tests in $file put on top block device."
xz -d -c $file | dd of=$DEV bs=1M 2>/dev/null || fail "bad image"
[ ! -d $MNT_DIR ] && mkdir $MNT_DIR
mount $DEV $MNT_DIR
if [ $? -ne 0 ]; then
echo "Mounting image $file failed, skipped."
continue;
fi
rm -rf $MNT_DIR/* 2>/dev/null
local tfile=$MNT_DIR/bwunit_tstfile
falloc $DEVSIZEMB $tfile || fail "enospc?"
local iobsize=$(stat -c "%o" $tfile)
test -n "$iobsize" -a $iobsize -gt 0 || fail
local oldbsize=$BSIZE
BSIZE=$iobsize
run_all $tfile
BSIZE=$oldbsize
umount $MNT_DIR
done
}

View File

@@ -14,8 +14,8 @@ cleanup() {
[ -b /dev/mapper/$DEV_NAME ] && dmsetup remove --retry $DEV_NAME
udevadm settle >/dev/null 2>&1
if [ -d "$MNT_DIR" ] ; then
umount -f $MNT_DIR 2>/dev/null
rmdir $MNT_DIR 2>/dev/null
umount -f $MNT_DIR 2>/dev/null
rmdir $MNT_DIR 2>/dev/null
fi
rmmod scsi_debug >/dev/null 2>&1
}

View File

@@ -340,80 +340,80 @@ int_mode() # alg tag_size sector_size [keyfile keysize]
check_device_size() # device_name expected_size error_message
{
CURRENT_SIZE=$(dmsetup table | grep $1 | cut -d' ' -f 3)
[ $CURRENT_SIZE -eq $2 ] || fail "$3: expected $1 to be of size $2, but is $CURRENT_SIZE"
CURRENT_SIZE=$(dmsetup table | grep $1 | cut -d' ' -f 3)
[ $CURRENT_SIZE -eq $2 ] || fail "$3: expected $1 to be of size $2, but is $CURRENT_SIZE"
}
test_resize() # description detached_metadata wipe args
{
echo -n "$1"
if [ -z "$DM_INTEGRITY_RESIZE_SUPPORTED" ] ; then
echo "[N/A]"
return
fi
echo -n "$1"
if [ -z "$DM_INTEGRITY_RESIZE_SUPPORTED" ] ; then
echo "[N/A]"
return
fi
args="$4"
if [ $2 -ne 0 ] ; then
echo -n "[DETACHED]"
else
echo -n "[INTERLEAVE]"
fi
if [ $3 -ne 0 ] ; then
wipe_flag="--wipe"
echo -n "[WIPE]"
else
wipe_flag=""
echo -n "[RECALCULATE]"
fi
args="$4"
if [ $2 -ne 0 ] ; then
echo -n "[DETACHED]"
else
echo -n "[INTERLEAVE]"
fi
if [ $3 -ne 0 ] ; then
wipe_flag="--wipe"
echo -n "[WIPE]"
else
wipe_flag=""
echo -n "[RECALCULATE]"
fi
add_device
if [ $2 -ne 0 ] ; then
echo -n "[FORMAT]"
$INTSETUP format -q $args $DEV2 --data-device $DEV >/dev/null 2>&1 || fail "Cannot format device."
echo -n "[ACTIVATE]"
$INTSETUP open -q $args $DEV2 $DEV_NAME --data-device $DEV >/dev/null 2>&1 || fail "Cannot activate device."
else
echo -n "[FORMAT]"
$INTSETUP format -q $args $DEV >/dev/null 2>&1 || fail "Cannot format device."
echo -n "[ACTIVATE]"
$INTSETUP open -q $args $DEV $DEV_NAME >/dev/null 2>&1 || fail "Cannot activate device."
fi
add_device
if [ $2 -ne 0 ] ; then
echo -n "[FORMAT]"
$INTSETUP format -q $args $DEV2 --data-device $DEV >/dev/null 2>&1 || fail "Cannot format device."
echo -n "[ACTIVATE]"
$INTSETUP open -q $args $DEV2 $DEV_NAME --data-device $DEV >/dev/null 2>&1 || fail "Cannot activate device."
else
echo -n "[FORMAT]"
$INTSETUP format -q $args $DEV >/dev/null 2>&1 || fail "Cannot format device."
echo -n "[ACTIVATE]"
$INTSETUP open -q $args $DEV $DEV_NAME >/dev/null 2>&1 || fail "Cannot activate device."
fi
if [ $2 -ne 0 ] ; then
# the whole device has 32MiB, if metadata is detached
WHOLE_DISK_SIZE=65536
else
WHOLE_DISK_SIZE=$(dmsetup table | grep $DEV_NAME | cut -d' ' -f 3)
fi
if [ $2 -ne 0 ] ; then
# the whole device has 32MiB, if metadata is detached
WHOLE_DISK_SIZE=65536
else
WHOLE_DISK_SIZE=$(dmsetup table | grep $DEV_NAME | cut -d' ' -f 3)
fi
echo -n "[SHRINK]"
$INTSETUP resize -q $wipe_flag $DEV_NAME --device-size 1MiB || fail "Failed to resize the device to 1MiB."
dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Errors detected after shrink."
check_device_size $DEV_NAME $(( 1024*1024 / 512 )) "Shrinking device failed"
echo -n "[SHRINK]"
$INTSETUP resize -q $wipe_flag $DEV_NAME --device-size 1MiB || fail "Failed to resize the device to 1MiB."
dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Errors detected after shrink."
check_device_size $DEV_NAME $(( 1024*1024 / 512 )) "Shrinking device failed"
echo -n "[FILL]"
$INTSETUP resize -q $wipe_flag $DEV_NAME --device-size 0 || fail "Failed to resize the device to maximum size."
dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Errors detected after resize to maximum size."
check_device_size $DEV_NAME $WHOLE_DISK_SIZE "Resizing disk to maximum size failed"
echo -n "[FILL]"
$INTSETUP resize -q $wipe_flag $DEV_NAME --device-size 0 || fail "Failed to resize the device to maximum size."
dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Errors detected after resize to maximum size."
check_device_size $DEV_NAME $WHOLE_DISK_SIZE "Resizing disk to maximum size failed"
echo -n "[EXPAND FIXED]"
fallocate $DEV --len 64M
$INTSETUP resize -q $wipe_flag $DEV_NAME --device-size 40MiB || fail "Failed to expand the device to a fixed size."
dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Errors detected after expanding to a fixed size."
check_device_size $DEV_NAME $(( 40*1024*1024 / 512 )) "Resizing disk after expanding to a fixed size failed"
echo -n "[EXPAND FIXED]"
fallocate $DEV --len 64M
$INTSETUP resize -q $wipe_flag $DEV_NAME --device-size 40MiB || fail "Failed to expand the device to a fixed size."
dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Errors detected after expanding to a fixed size."
check_device_size $DEV_NAME $(( 40*1024*1024 / 512 )) "Resizing disk after expanding to a fixed size failed"
echo -n "[FILL]"
$INTSETUP resize -q $wipe_flag $DEV_NAME --device-size 0 >/dev/null 2>&1 || fail "Failed to resize the device to maximum size after increasing image size."
dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Error detection failed after increasing image size."
CURRENT_SIZE=$(dmsetup table | grep $DEV_NAME | cut -d' ' -f 3)
[ $CURRENT_SIZE -ge $(( 40*1024*1024 / 512 )) ] || fail "Growing integrity device failed $CURRENT_SIZE is not greater than 40MB ($(( 40*1024*1024 / 512 )) blocks)."
if [ $2 -ne 0 ] ; then
[ $CURRENT_SIZE -eq 131072 ] || fail "Growing integrity device failed $CURRENT_SIZE is not equal to 64MB (131072 blocks)."
fi
echo -n "[FILL]"
$INTSETUP resize -q $wipe_flag $DEV_NAME --device-size 0 >/dev/null 2>&1 || fail "Failed to resize the device to maximum size after increasing image size."
dd if=/dev/mapper/$DEV_NAME >/dev/null 2>&1 || fail "Error detection failed after increasing image size."
CURRENT_SIZE=$(dmsetup table | grep $DEV_NAME | cut -d' ' -f 3)
[ $CURRENT_SIZE -ge $(( 40*1024*1024 / 512 )) ] || fail "Growing integrity device failed $CURRENT_SIZE is not greater than 40MB ($(( 40*1024*1024 / 512 )) blocks)."
if [ $2 -ne 0 ] ; then
[ $CURRENT_SIZE -eq 131072 ] || fail "Growing integrity device failed $CURRENT_SIZE is not equal to 64MB (131072 blocks)."
fi
echo -n "[REMOVE]"
$INTSETUP close $DEV_NAME || fail "Cannot deactivate device."
echo "[OK]"
echo -n "[REMOVE]"
$INTSETUP close $DEV_NAME || fail "Cannot deactivate device."
echo "[OK]"
}
[ $(id -u) != 0 ] && skip "WARNING: You must be root to run this test, test skipped."

View File

@@ -278,11 +278,11 @@ function check_fec()
else
echo -n "[repaired in kernel]"
$VERITYSETUP verify $1 $2 $ROOT_HASH --fec-device=$3 $PARAMS >/dev/null 2>&1 || fail "Userspace verify failed"
echo "[userspace verify][OK]"
RET=0
fi
echo "[userspace verify][OK]"
RET=0
fi
rm $1 $2 $3 $IMG_TMP > /dev/null 2>&1
return $RET
return $RET
}
function check_option() # $1 size, $2 hash, $3 salt, $4 version, $5 hash, $6 CLI option, $7 status option
@@ -536,17 +536,17 @@ $VERITYSETUP close $DEV_NAME >/dev/null 2>&1 && fail
$VERITYSETUP status $DEV_NAME >/dev/null 2>&1 || fail
$VERITYSETUP close --deferred $DEV_NAME >/dev/null 2>&1
if [ $? -eq 0 ] ; then
dmsetup info $DEV_NAME | grep -q "DEFERRED REMOVE" || fail
$VERITYSETUP close --cancel-deferred $DEV_NAME >/dev/null 2>&1
dmsetup info $DEV_NAME | grep -q "DEFERRED REMOVE" >/dev/null 2>&1 && fail
$VERITYSETUP close --deferred $DEV_NAME >/dev/null 2>&1
dmsetup remove $DEV_NAME2 || fail
$VERITYSETUP status $DEV_NAME >/dev/null 2>&1 && fail
echo "[OK]"
dmsetup info $DEV_NAME | grep -q "DEFERRED REMOVE" || fail
$VERITYSETUP close --cancel-deferred $DEV_NAME >/dev/null 2>&1
dmsetup info $DEV_NAME | grep -q "DEFERRED REMOVE" >/dev/null 2>&1 && fail
$VERITYSETUP close --deferred $DEV_NAME >/dev/null 2>&1
dmsetup remove $DEV_NAME2 || fail
$VERITYSETUP status $DEV_NAME >/dev/null 2>&1 && fail
echo "[OK]"
else
dmsetup remove $DEV_NAME2 >/dev/null 2>&1
$VERITYSETUP close $DEV_NAME >/dev/null 2>&1
echo "[N/A]"
dmsetup remove $DEV_NAME2 >/dev/null 2>&1
$VERITYSETUP close $DEV_NAME >/dev/null 2>&1
echo "[N/A]"
fi
remove_mapping