fstests: _fail test by default when _scratch_mount fails

Previously _scratch_mount didn't check the mount status and most
tests continue to run even if the mount failed (unless test checks
for the mount status explicitly). This would result in running tests
on the underlying filesystem (usually rootfs) and implicit test
failures, and such failures can be annoying and are usually hard to
debug.

Now _fail test by default if _scratch_mount failed and introduce
_try_scratch_mount for tests that need to check mount results
themselves.

Suggested-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
Eryu Guan
2018-02-07 17:31:36 +08:00
parent 729381bda4
commit 69eb6281a9
109 changed files with 184 additions and 192 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ rm -f $seqres.full
$MKFS_EXT4_PROG -F -O bigalloc -C 65536 -g 256 $SCRATCH_DEV 512m \
>> $seqres.full 2>&1
_scratch_mount || _fail "couldn't mount fs"
_scratch_mount
$XFS_IO_PROG -f -c "pwrite 0 256m -b 1M" $SCRATCH_MNT/testfile 2>&1 | \
_filter_xfs_io
+2 -2
View File
@@ -112,7 +112,7 @@ echo "++ corrupt image" >> $seqres.full
e2fuzz ${FUZZ_ARGS} ${SCRATCH_DEV} >> $seqres.full 2>&1
echo "++ mount image" >> $seqres.full
_scratch_mount >> $seqres.full 2>&1
_try_scratch_mount >> $seqres.full 2>&1
echo "++ test scratch" >> $seqres.full
_scratch_fuzz_test >> $seqres.full 2>&1
@@ -134,7 +134,7 @@ _check_scratch_fs >> $seqres.full 2>&1
ROUND2_LOG="${tmp}-round2-${fsck_pass}.log"
echo "++ mount image (2)" >> $ROUND2_LOG
_scratch_mount >> $ROUND2_LOG 2>&1
_try_scratch_mount >> $ROUND2_LOG 2>&1
echo "++ chattr -R -i" >> $ROUND2_LOG
$CHATTR_PROG -R -f -i "${SCRATCH_MNT}/" > /dev/null 2>> $ROUND2_LOG
+1 -1
View File
@@ -89,7 +89,7 @@ dumpe2fs -g "${SCRATCH_DEV}" 2>/dev/null | awk -F ':' '{if ($1 == 0) {print $3}}
done
echo "+ mount image"
_scratch_mount 2> /dev/null && _fail "mount should not succeed"
_try_scratch_mount 2> /dev/null && _fail "mount should not succeed"
echo "+ repair fs"
# Have to specify backup sb and blocksize here so we don't pick up superblocks
+1 -1
View File
@@ -85,7 +85,7 @@ dumpe2fs -g "${SCRATCH_DEV}" 2>/dev/null | awk -F ':' '{if (int($4) != -1) {prin
done
echo "+ mount image"
_scratch_mount 2> /dev/null && _fail "mount should not succeed"
_try_scratch_mount 2> /dev/null && _fail "mount should not succeed"
echo "+ repair fs"
e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
+2 -2
View File
@@ -73,13 +73,13 @@ blk="$(dumpe2fs "${SCRATCH_DEV}" 2> /dev/null | grep 'MMP block number' | sed -e
$XFS_IO_PROG -f -c "pwrite -S 0x62 $((blk * blksz + 16)) 8" "${SCRATCH_DEV}" >> $seqres.full
echo "+ mount image"
_scratch_mount 2> /dev/null && _fail "mount should fail due to bad MMP"
_try_scratch_mount 2> /dev/null && _fail "mount should fail due to bad MMP"
echo "+ repair fs"
e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
echo "+ mount image (2)"
_scratch_mount || _fail "mount should not fail; MMP has been fixed"
_try_scratch_mount || _fail "mount should not fail; MMP has been fixed"
echo "+ check fs (2)"
e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+2 -2
View File
@@ -72,13 +72,13 @@ echo "+ corrupt image"
debugfs -w -R 'zap -f <8> 0' "${SCRATCH_DEV}" 2> /dev/null
echo "+ mount image"
_scratch_mount 2> /dev/null && _fail "mount should fail due to bad journal"
_try_scratch_mount 2> /dev/null && _fail "mount should fail due to bad journal"
echo "+ repair fs"
e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1
echo "+ mount image (2)"
_scratch_mount || _fail "mount should not fail; journal has been fixed"
_try_scratch_mount || _fail "mount should not fail; journal has been fixed"
echo "+ check fs (2)"
e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail"
+1 -1
View File
@@ -79,7 +79,7 @@ _scratch_unmount
debugfs -w -R "set_super_value s_last_orphan $inum" $SCRATCH_DEV &>>$seqres.full
# Try to mount the filesystem. This would hit a BUG() in fs/ext4/inode.c.
_scratch_mount
_try_scratch_mount
# success, all done
echo "Didn't crash!"
+1 -1
View File
@@ -58,7 +58,7 @@ _scratch_mkfs "-O bigalloc,meta_bg,^resize_inode" >> $seqres.full 2>&1
$DEBUGFS_PROG -w -R "ssv first_meta_bg 842150400" $SCRATCH_DEV >> $seqres.full 2>&1
echo "Try to mount a modified ext4 fs"
_scratch_mount >> $seqres.full 2>&1 || echo "Fail to mount ext4 fs expectedly"
_try_scratch_mount >> $seqres.full 2>&1 || echo "Fail to mount ext4 fs expectedly"
# success, all done
status=0
+1 -1
View File
@@ -61,7 +61,7 @@ PIDS=$!
# 30 loops is enough to crash a buggy kernel
i=0
while [ $i -lt 30 ]; do
_scratch_mount
_try_scratch_mount
_scratch_unmount
let i=i+1
done
+1 -1
View File
@@ -53,7 +53,7 @@ if grep -q 64bit /etc/mke2fs.conf ; then
features="^extents,^64bit"
fi
$MKFS_EXT4_PROG -F -O "$features" $SCRATCH_DEV 512m >> $seqres.full 2>&1
_scratch_mount || _fail "couldn't mount fs"
_scratch_mount
# Create a small non-extent-based file
echo "Create 1m testfile1"