summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@suse.de>2024-04-30 01:37:52 +1000
committerZorro Lang <zlang@kernel.org>2024-05-12 20:28:48 +0800
commit41474afbed5b3a215061c81815c83323d3d2accc (patch)
treec0536bb96916949bfda9a2bfb9f57a97ad160f55
parentb26d68da08e47e6508a96bee72b25823040ab67e (diff)
tests: _fail on _scratch_mkfs_sized failure
If _scratch_mkfs_sized() fails, e.g. due to an FS not supporting the provided size, tests may subsequently mount and run atop a previously created (e.g. non-size-bound) filesystem. This can lead to difficult to debug failures, or for some -ENOSPC exercising tests, near infinite runtimes. Avoid this by renaming the current function to _try_scratch_mkfs_sized() and _fail in the parent _scratch_mkfs_sized() wrapper. [zlang: change _fail output, remove missed _fail in b/007, fix g/466] Suggested-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: David Disseldorp <ddiss@suse.de> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
-rw-r--r--common/rc9
-rwxr-xr-xtests/btrfs/0043
-rwxr-xr-xtests/btrfs/0076
-rwxr-xr-xtests/ext4/0212
-rwxr-xr-xtests/ext4/0592
-rwxr-xr-xtests/generic/0153
-rwxr-xr-xtests/generic/0772
-rwxr-xr-xtests/generic/0833
-rwxr-xr-xtests/generic/1712
-rwxr-xr-xtests/generic/1722
-rwxr-xr-xtests/generic/1732
-rwxr-xr-xtests/generic/1742
-rwxr-xr-xtests/generic/4662
-rwxr-xr-xtests/generic/7352
-rwxr-xr-xtests/xfs/0152
-rwxr-xr-xtests/xfs/0573
16 files changed, 23 insertions, 24 deletions
diff --git a/common/rc b/common/rc
index 56f1afb6..3f4864d0 100644
--- a/common/rc
+++ b/common/rc
@@ -968,8 +968,8 @@ _small_fs_size_mb()
}
# Create fs of certain size on scratch device
-# _scratch_mkfs_sized <size in bytes> [optional blocksize]
-_scratch_mkfs_sized()
+# _try_scratch_mkfs_sized <size in bytes> [optional blocksize]
+_try_scratch_mkfs_sized()
{
local fssize=$1
local blocksize=$2
@@ -1111,6 +1111,11 @@ _scratch_mkfs_sized()
esac
}
+_scratch_mkfs_sized()
+{
+ _try_scratch_mkfs_sized $* || _fail "_scratch_mkfs_sized failed with ($*)"
+}
+
# Emulate an N-data-disk stripe w/ various stripe units
# _scratch_mkfs_geom <sunit bytes> <swidth multiplier> [optional blocksize]
_scratch_mkfs_geom()
diff --git a/tests/btrfs/004 b/tests/btrfs/004
index 00a516c3..684f5fdf 100755
--- a/tests/btrfs/004
+++ b/tests/btrfs/004
@@ -157,8 +157,7 @@ workout()
_scratch_unmount >/dev/null 2>&1
echo "*** mkfs -dsize=$fsz" >>$seqres.full
echo "" >>$seqres.full
- _scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
- || _fail "size=$fsz mkfs failed"
+ _scratch_mkfs_sized $fsz >>$seqres.full 2>&1
_scratch_mount
# -w ensures that the only ops are ones which cause write I/O
run_check $FSSTRESS_PROG -d $SCRATCH_MNT -w -p $procs -n 2000 \
diff --git a/tests/btrfs/007 b/tests/btrfs/007
index 333524e2..5b9a887b 100755
--- a/tests/btrfs/007
+++ b/tests/btrfs/007
@@ -43,8 +43,7 @@ workout()
_scratch_unmount >/dev/null 2>&1
echo "*** mkfs -dsize=$fsz" >>$seqres.full
echo "" >>$seqres.full
- _scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
- || _fail "size=$fsz mkfs failed"
+ _scratch_mkfs_sized $fsz >>$seqres.full 2>&1
_scratch_mount "-o noatime"
run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n $ops $FSSTRESS_AVOID -x \
@@ -70,8 +69,7 @@ workout()
_scratch_unmount >/dev/null 2>&1
echo "*** mkfs -dsize=$fsz" >>$seqres.full
echo "" >>$seqres.full
- _scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
- || _fail "size=$fsz mkfs failed"
+ _scratch_mkfs_sized $fsz >>$seqres.full 2>&1
_scratch_mount "-o noatime"
_btrfs receive $SCRATCH_MNT < $send_files_dir/base.snap
diff --git a/tests/ext4/021 b/tests/ext4/021
index a9277abf..62768c60 100755
--- a/tests/ext4/021
+++ b/tests/ext4/021
@@ -24,7 +24,7 @@ _scratch_unmount
# With 4k block size, this amounts to 10M FS instance.
fssize=$((2560 * $blocksize))
-_scratch_mkfs_sized $fssize >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mkfs_sized $fssize >> $seqres.full 2>&1
_require_metadata_journaling $SCRATCH_DEV
offset=0
diff --git a/tests/ext4/059 b/tests/ext4/059
index 4230bde9..f4864ffc 100755
--- a/tests/ext4/059
+++ b/tests/ext4/059
@@ -23,7 +23,7 @@ _require_scratch_size_nocheck $((1024 * 1024))
# Initalize a 512M ext4 fs with resize_inode feature disabled
dev_size=$((512 * 1024 * 1024))
MKFS_OPTIONS="-O ^resize_inode $MKFS_OPTIONS" _scratch_mkfs_sized $dev_size \
- >>$seqres.full 2>&1 || _fail "mkfs failed"
+ >>$seqres.full 2>&1
# Force some reserved GDT blocks to trigger the bug
$DEBUGFS_PROG -w -R "set_super_value s_reserved_gdt_blocks 100" $SCRATCH_DEV \
diff --git a/tests/generic/015 b/tests/generic/015
index 10423a29..716a7b1f 100755
--- a/tests/generic/015
+++ b/tests/generic/015
@@ -31,8 +31,7 @@ _require_no_large_scratch_dev
# btrfs needs at least 256MB (with upward round off) to create a non-mixed mode
# fs. Ref: btrfs-progs: btrfs_min_dev_size()
-_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1 \
- || _fail "mkfs failed"
+_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
_scratch_mount
out=$SCRATCH_MNT/fillup.$$
diff --git a/tests/generic/077 b/tests/generic/077
index 94d89fae..2624e88f 100755
--- a/tests/generic/077
+++ b/tests/generic/077
@@ -50,7 +50,7 @@ _scratch_unmount >/dev/null 2>&1
echo "*** MKFS ***" >>$seqres.full
echo "" >>$seqres.full
fs_size=$((256 * 1024 * 1024))
-_scratch_mkfs_sized $fs_size >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mkfs_sized $fs_size >> $seqres.full 2>&1
_scratch_mount
mkdir $SCRATCH_MNT/subdir
diff --git a/tests/generic/083 b/tests/generic/083
index 2a5af3cc..4cd1c399 100755
--- a/tests/generic/083
+++ b/tests/generic/083
@@ -50,8 +50,7 @@ workout()
_scratch_mkfs_xfs -dsize=$fsz,agcount=$ags >>$seqres.full 2>&1 \
|| _fail "size=$fsz,agcount=$ags mkfs failed"
else
- _scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
- || _fail "size=$fsz mkfs failed"
+ _scratch_mkfs_sized $fsz >>$seqres.full 2>&1
fi
_scratch_mount
diff --git a/tests/generic/171 b/tests/generic/171
index f823a454..fb2a6f14 100755
--- a/tests/generic/171
+++ b/tests/generic/171
@@ -42,7 +42,7 @@ sz_bytes=$((nr_blks * 8 * blksz))
if [ $sz_bytes -lt $((32 * 1048576)) ]; then
sz_bytes=$((32 * 1048576))
fi
-_scratch_mkfs_sized $sz_bytes >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mkfs_sized $sz_bytes >> $seqres.full 2>&1
_scratch_mount >> $seqres.full 2>&1
rm -rf $testdir
mkdir $testdir
diff --git a/tests/generic/172 b/tests/generic/172
index 383824b9..ab5122fa 100755
--- a/tests/generic/172
+++ b/tests/generic/172
@@ -40,7 +40,7 @@ umount $SCRATCH_MNT
file_size=$((768 * 1024 * 1024))
fs_size=$((1024 * 1024 * 1024))
-_scratch_mkfs_sized $fs_size >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mkfs_sized $fs_size >> $seqres.full 2>&1
_scratch_mount >> $seqres.full 2>&1
rm -rf $testdir
mkdir $testdir
diff --git a/tests/generic/173 b/tests/generic/173
index e1493278..0eb313e2 100755
--- a/tests/generic/173
+++ b/tests/generic/173
@@ -42,7 +42,7 @@ sz_bytes=$((nr_blks * 8 * blksz))
if [ $sz_bytes -lt $((32 * 1048576)) ]; then
sz_bytes=$((32 * 1048576))
fi
-_scratch_mkfs_sized $sz_bytes >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mkfs_sized $sz_bytes >> $seqres.full 2>&1
_scratch_mount >> $seqres.full 2>&1
rm -rf $testdir
mkdir $testdir
diff --git a/tests/generic/174 b/tests/generic/174
index c7a177b8..1505453e 100755
--- a/tests/generic/174
+++ b/tests/generic/174
@@ -43,7 +43,7 @@ sz_bytes=$((nr_blks * 8 * blksz))
if [ $sz_bytes -lt $((32 * 1048576)) ]; then
sz_bytes=$((32 * 1048576))
fi
-_scratch_mkfs_sized $sz_bytes >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mkfs_sized $sz_bytes >> $seqres.full 2>&1
_scratch_mount >> $seqres.full 2>&1
rm -rf $testdir
mkdir $testdir
diff --git a/tests/generic/466 b/tests/generic/466
index 4059c9ea..05bfd501 100755
--- a/tests/generic/466
+++ b/tests/generic/466
@@ -30,7 +30,7 @@ for blocksize in 512 1024 2048 4096 8192 16384 32768 65536; do
_scratch_unmount > /dev/null 2>&1
# Try to format and mount with the given blocksize. If they don't
# succeed, move on to the next block size.
- if ! _scratch_mkfs_sized $devsize $blocksize >> $seqres.full 2>&1 ||
+ if ! _try_scratch_mkfs_sized $devsize $blocksize >> $seqres.full 2>&1 ||
! _try_scratch_mount >> $seqres.full 2>&1 ||
test "$(stat -f -c '%S' $SCRATCH_MNT)" -ne "$blocksize"; then
echo "+++ Format and mount failed" >> $seqres.full
diff --git a/tests/generic/735 b/tests/generic/735
index 0ba111a6..89107a61 100755
--- a/tests/generic/735
+++ b/tests/generic/735
@@ -25,7 +25,7 @@ _require_xfs_io_command "falloc"
_require_xfs_io_command "finsert"
dev_size=$((80 * 1024 * 1024))
-_scratch_mkfs_sized $dev_size >>$seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mkfs_sized $dev_size >>$seqres.full 2>&1
_scratch_mount
_require_congruent_file_oplen $SCRATCH_MNT 1048576 # finsert at 1M
diff --git a/tests/xfs/015 b/tests/xfs/015
index a7f4d243..3896ce1c 100755
--- a/tests/xfs/015
+++ b/tests/xfs/015
@@ -43,7 +43,7 @@ _scratch_mount
_require_fs_space $SCRATCH_MNT 196608
_scratch_unmount
-_scratch_mkfs_sized $((96 * 1024 * 1024)) > $tmp.mkfs.raw || _fail "mkfs failed"
+_scratch_mkfs_sized $((96 * 1024 * 1024)) > $tmp.mkfs.raw
cat $tmp.mkfs.raw | _filter_mkfs >$seqres.full 2>$tmp.mkfs
# get original data blocks number and agcount
. $tmp.mkfs
diff --git a/tests/xfs/057 b/tests/xfs/057
index 6af14c80..0cf16701 100755
--- a/tests/xfs/057
+++ b/tests/xfs/057
@@ -51,8 +51,7 @@ echo "Silence is golden."
sdev=$(_short_dev $SCRATCH_DEV)
# use a small log fs
-_scratch_mkfs_sized $((1024 * 1024 * 500)) >> $seqres.full 2>&1 ||
- _fail "mkfs failed"
+_scratch_mkfs_sized $((1024 * 1024 * 500)) >> $seqres.full 2>&1
_scratch_mount
# populate the fs with some data and cycle the mount to reset the log head/tail