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
@@ -229,7 +229,7 @@ _require_noattr2()
{
_scratch_mkfs_xfs > /dev/null 2>&1 \
|| _fail "_scratch_mkfs_xfs failed on $SCRATCH_DEV"
_scratch_mount -o noattr2 > /dev/null 2>&1 \
_try_scratch_mount -o noattr2 > /dev/null 2>&1 \
|| _notrun "noattr2 mount option not supported on $SCRATCH_DEV"
_scratch_unmount
}
+2 -2
View File
@@ -31,10 +31,10 @@ _dmapi_scratch_mount () {
if [ `echo "$MOUNT_OPTIONS" | grep -c dmapi` -gt 0 -o \
`echo "$MOUNT_OPTIONS" | grep -c dmi` -gt 0 ] ; then
#already got dmapi options set
_scratch_mount
_try_scratch_mount
dmapi_mount_result=$?
else
_scratch_mount "-o dmapi,mtpt=$SCRATCH_MNT"
_try_scratch_mount "-o dmapi,mtpt=$SCRATCH_MNT"
dmapi_mount_result=$?
fi
+2 -2
View File
@@ -235,7 +235,7 @@ _wipe_fs()
_require_scratch
_scratch_mkfs_xfs >>$seqres.full || _fail "mkfs failed"
_scratch_mount >>$seqres.full || _fail "mount failed"
_scratch_mount >>$seqres.full
}
#
@@ -287,7 +287,7 @@ _stable_fs()
{
_saveddir=`pwd`; cd /
_scratch_unmount >>$seqres.full || _fail "unmount failed"
_scratch_mount >>$seqres.full || _fail "mount failed"
_scratch_mount >>$seqres.full
cd $_saveddir
}
+1 -1
View File
@@ -43,7 +43,7 @@ _require_scratch_encryption()
# Try to mount the filesystem. If this fails then either the kernel
# isn't aware of encryption, or the mkfs options were not compatible
# with encryption (e.g. ext4 with block size != PAGE_SIZE).
if ! _scratch_mount &>>$seqres.full; then
if ! _try_scratch_mount &>>$seqres.full; then
_notrun "kernel is unaware of $FSTYP encryption feature," \
"or mkfs options are not compatible with encryption"
fi
+2 -2
View File
@@ -111,11 +111,11 @@ _test_streams() {
if [ "$use_iflag" = "0" ]; then
# mount using filestreams mount option
_scratch_mount "-o filestreams" \
_try_scratch_mount "-o filestreams" \
|| _fail "filestreams mount failed"
else
# test will set inode flag
_scratch_mount || _fail "mount failed"
_scratch_mount
fi
cd $SCRATCH_MNT
+2 -2
View File
@@ -200,7 +200,7 @@ __scratch_xfs_fuzz_field_test() {
# Try to catch the error with scrub
echo "+ Try to catch the error"
_scratch_mount 2>&1
_try_scratch_mount 2>&1
res=$?
if [ $res -eq 0 ]; then
# Try an online scrub unless we're fuzzing ag 0's sb,
@@ -245,7 +245,7 @@ __scratch_xfs_fuzz_field_test() {
# See if scrub finds a clean fs
echo "+ Make sure error is gone (online)"
_scratch_mount 2>&1
_try_scratch_mount 2>&1
res=$?
if [ $res -eq 0 ]; then
# Try an online scrub unless we're fuzzing ag 0's sb,
+3 -3
View File
@@ -370,7 +370,7 @@ _create_log()
{
# mount the FS
_full "mount"
_scratch_mount >>$seqres.full 2>&1
_try_scratch_mount >>$seqres.full 2>&1
if [ $? -ne 0 ] ; then
_echofull "mount failed: $MOUNT_OPTIONS"
return 1
@@ -399,7 +399,7 @@ _create_log_sync()
{
# mount the FS
_full " mount"
_scratch_mount >>$seqres.full 2>&1
_try_scratch_mount >>$seqres.full 2>&1
if [ $? -ne 0 ] ; then
_echofull "mount failed: $MOUNT_OPTIONS"
return 1
@@ -519,7 +519,7 @@ _require_v2log()
# test out mount to see if it mounts a v2 log fs
export MOUNT_OPTIONS="-o logbsize=32k"
if ! _scratch_mount >>$seqres.full 2>&1; then
if ! _try_scratch_mount >>$seqres.full 2>&1; then
_notrun "mount/kernel does not support v2 logs"
fi
+1 -1
View File
@@ -167,7 +167,7 @@ _require_scratch_overlay_features()
done
_scratch_mkfs > /dev/null 2>&1
_scratch_mount -o $opts || \
_try_scratch_mount -o $opts || \
_notrun "overlay options '$opts' cannot be enabled on ${SCRATCH_DEV}"
for feature in ${features[*]}; do
+1 -1
View File
@@ -131,7 +131,7 @@ _test_punch() {
_dmapi_scratch_mount
else
# only unresvsp punch type is used, just do a normal mount
_scratch_mount || _fail "mount failed"
_scratch_mount
fi
cd $SCRATCH_MNT
+2 -2
View File
@@ -119,7 +119,7 @@ _scratch_enable_pquota()
[ "$FSTYP" != "ext4" ] && return
tune2fs -O quota,project $SCRATCH_DEV >>$seqres.full 2>&1
_scratch_mount >/dev/null 2>&1 \
_try_scratch_mount >/dev/null 2>&1 \
|| _notrun "kernel doesn't support project feature on $FSTYP"
_scratch_unmount
}
@@ -202,7 +202,7 @@ _choose_prid()
_qmount()
{
_scratch_unmount >/dev/null 2>&1
_scratch_mount || _fail "qmount failed"
_try_scratch_mount || _fail "qmount failed"
# xfs doesn't need these setups and quotacheck even fails on xfs
# redirect the output to $seqres.full for debug purpose and ignore results
if [ "$FSTYP" != "xfs" ]; then
+24 -16
View File
@@ -352,13 +352,20 @@ _supports_filetype()
esac
}
# mount scratch device with given options but don't check mount status
_try_scratch_mount()
{
if [ "$FSTYP" == "overlay" ]; then
_overlay_scratch_mount $*
return $?
fi
_mount -t $FSTYP `_scratch_mount_options $*`
}
# mount scratch device with given options and _fail if mount fails
_scratch_mount()
{
if [ "$FSTYP" == "overlay" ]; then
_overlay_scratch_mount $*
return $?
fi
_mount -t $FSTYP `_scratch_mount_options $*`
_try_scratch_mount $* || _fail "mount failed"
}
_scratch_unmount()
@@ -397,7 +404,7 @@ _scratch_cycle_mount()
opts="-o $opts"
fi
_scratch_unmount
_scratch_mount "$opts"
_try_scratch_mount "$opts" || _fail "cycle mount failed"
}
_scratch_shutdown()
@@ -524,7 +531,7 @@ _setup_large_ext4_fs()
# mount the filesystem and create 16TB - 4KB files until we consume
# all the necessary space.
_scratch_mount 2>&1 >$tmp_dir/mnt.err
_try_scratch_mount 2>&1 >$tmp_dir/mnt.err
local status=$?
if [ $status -ne 0 ]; then
echo "mount failed"
@@ -1103,7 +1110,7 @@ _repair_scratch_fs()
res=$?
if [ "$res" -ne 0 ]; then
echo "xfs_repair returns $res; replay log?"
_scratch_mount
_try_scratch_mount
res=$?
if [ "$res" -gt 0 ]; then
echo "mount returns $res; zap log?"
@@ -1872,7 +1879,7 @@ _require_scratch_ext4_crc()
{
_scratch_mkfs_ext4 >/dev/null 2>&1
dumpe2fs -h $SCRATCH_DEV 2> /dev/null | grep -q metadata_csum || _notrun "metadata_csum not supported by this filesystem"
_scratch_mount >/dev/null 2>&1 \
_try_scratch_mount >/dev/null 2>&1 \
|| _notrun "Kernel doesn't support metadata_csum feature"
_scratch_unmount
}
@@ -1888,7 +1895,7 @@ _require_scratch_ext4_feature()
$MKFS_EXT4_PROG -F $MKFS_OPTIONS -O "$1" \
$SCRATCH_DEV 512m >/dev/null 2>&1 \
|| _notrun "mkfs.ext4 doesn't support $1 feature"
_scratch_mount >/dev/null 2>&1 \
_try_scratch_mount >/dev/null 2>&1 \
|| _notrun "Kernel doesn't support the ext4 feature(s): $1"
_scratch_unmount
}
@@ -2322,7 +2329,7 @@ _require_scratch_richacl_xfs()
_scratch_mkfs_xfs_supported -m richacl=1 >/dev/null 2>&1 \
|| _notrun "mkfs.xfs doesn't have richacl feature"
_scratch_mkfs_xfs -m richacl=1 >/dev/null 2>&1
_scratch_mount >/dev/null 2>&1 \
_try_scratch_mount >/dev/null 2>&1 \
|| _notrun "kernel doesn't support richacl feature on $FSTYP"
_scratch_unmount
}
@@ -2331,7 +2338,7 @@ _require_scratch_richacl_ext4()
{
_scratch_mkfs -O richacl >/dev/null 2>&1 \
|| _notrun "can't mkfs $FSTYP with option -O richacl"
_scratch_mount >/dev/null 2>&1 \
_try_scratch_mount >/dev/null 2>&1 \
|| _notrun "kernel doesn't support richacl feature on $FSTYP"
_scratch_unmount
}
@@ -2993,7 +3000,7 @@ _require_scratch_shutdown()
[ -x src/godown ] || _notrun "src/godown executable not found"
_scratch_mkfs > /dev/null 2>&1 || _notrun "_scratch_mkfs failed on $SCRATCH_DEV"
_scratch_mount || _notrun "_scratch_mount failed on $SCRATCH_MNT"
_scratch_mount
if [ $FSTYP = "overlay" ]; then
if [ -z $OVL_BASE_SCRATCH_DEV ]; then
@@ -3019,7 +3026,8 @@ _require_scratch_dax()
{
_require_scratch
_scratch_mkfs > /dev/null 2>&1
_scratch_mount -o dax
_try_scratch_mount -o dax || \
_notrun "mount $SCRATCH_DEV with dax failed"
# Check options to be sure. XFS ignores dax option
# and goes on if dev underneath does not support dax.
_fs_options $SCRATCH_DEV | grep -qw "dax" || \
@@ -3030,7 +3038,7 @@ _require_scratch_dax()
# Does norecovery support by this fs?
_require_norecovery()
{
_scratch_mount -o ro,norecovery || \
_try_scratch_mount -o ro,norecovery || \
_notrun "$FSTYP does not support norecovery"
_scratch_unmount
}
@@ -3229,7 +3237,7 @@ _require_atime()
_require_relatime()
{
_scratch_mkfs > /dev/null 2>&1
_scratch_mount -o relatime || \
_try_scratch_mount -o relatime || \
_notrun "relatime not supported by the current kernel"
_scratch_unmount
}
+6 -6
View File
@@ -18,7 +18,7 @@ _setup_large_xfs_fs()
file_size=$(($file_size - $SCRATCH_DEV_EMPTY_SPACE))
# mount the filesystem, create the file, unmount it
_scratch_mount 2>&1 >$tmp_dir/mnt.err
_try_scratch_mount 2>&1 >$tmp_dir/mnt.err
local status=$?
if [ $status -ne 0 ]; then
echo "mount failed"
@@ -223,7 +223,7 @@ _require_xfs_mkfs_crc()
_require_xfs_crc()
{
_scratch_mkfs_xfs -m crc=1 >/dev/null 2>&1
_scratch_mount >/dev/null 2>&1 \
_try_scratch_mount >/dev/null 2>&1 \
|| _notrun "Kernel doesn't support crc feature"
_scratch_unmount
}
@@ -233,7 +233,7 @@ _require_xfs_crc()
_require_scratch_xfs_crc()
{
_scratch_mkfs_xfs >/dev/null 2>&1
_scratch_mount >/dev/null 2>&1 \
_try_scratch_mount >/dev/null 2>&1 \
|| _notrun "Kernel doesn't support crc feature"
xfs_info $SCRATCH_MNT | grep -q 'crc=1' || _notrun "crc feature not supported by this filesystem"
_scratch_unmount
@@ -252,7 +252,7 @@ _require_xfs_mkfs_finobt()
_require_xfs_finobt()
{
_scratch_mkfs_xfs -m crc=1,finobt=1 >/dev/null 2>&1
_scratch_mount >/dev/null 2>&1 \
_try_scratch_mount >/dev/null 2>&1 \
|| _notrun "Kernel doesn't support finobt feature"
_scratch_unmount
}
@@ -280,7 +280,7 @@ _require_xfs_sparse_inodes()
_scratch_mkfs_xfs_supported -m crc=1 -i sparse > /dev/null 2>&1 \
|| _notrun "mkfs.xfs does not support sparse inodes"
_scratch_mkfs_xfs -m crc=1 -i sparse > /dev/null 2>&1
_scratch_mount >/dev/null 2>&1 \
_try_scratch_mount >/dev/null 2>&1 \
|| _notrun "kernel does not support sparse inodes"
_scratch_unmount
}
@@ -599,7 +599,7 @@ _require_meta_uuid()
_scratch_xfs_db -x -c "uuid generate" >/dev/null 2>&1
_scratch_mount >/dev/null 2>&1 \
_try_scratch_mount >/dev/null 2>&1 \
|| _notrun "Kernel doesn't support meta_uuid feature"
_scratch_unmount
}
+3 -3
View File
@@ -185,7 +185,7 @@ workout()
echo "" >>$seqres.full
_scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
|| _fail "size=$fsz mkfs failed"
run_check _scratch_mount
_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 \
$FSSTRESS_AVOID
@@ -194,7 +194,7 @@ workout()
$SCRATCH_MNT/$snap_name
run_check _scratch_unmount >/dev/null 2>&1
run_check _scratch_mount "-o compress=lzo"
_scratch_mount "-o compress=lzo"
# make some noise but ensure we're not touching existing data
# extents.
@@ -208,7 +208,7 @@ workout()
run_check $FSSTRESS_PROG -d $clean_dir -w -p $procs -n 2000 \
$FSSTRESS_AVOID
run_check _scratch_unmount >/dev/null 2>&1
run_check _scratch_mount "-o atime"
_scratch_mount "-o atime"
if [ $do_bg_noise -ne 0 ]; then
# make background noise while backrefs are being walked
+2 -2
View File
@@ -65,7 +65,7 @@ workout()
echo "" >>$seqres.full
_scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
|| _fail "size=$fsz mkfs failed"
run_check _scratch_mount "-o noatime"
_scratch_mount "-o noatime"
run_check $FSSTRESS_PROG -d $SCRATCH_MNT -n $ops $FSSTRESS_AVOID -x \
"$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/base"
@@ -91,7 +91,7 @@ workout()
echo "" >>$seqres.full
_scratch_mkfs_sized $fsz >>$seqres.full 2>&1 \
|| _fail "size=$fsz mkfs failed"
run_check _scratch_mount "-o noatime"
_scratch_mount "-o noatime"
_run_btrfs_util_prog receive $SCRATCH_MNT < $tmp/base.snap
run_check $FSSUM_PROG -r $tmp/base.fssum $SCRATCH_MNT/base
+1 -1
View File
@@ -59,7 +59,7 @@ $BTRFS_UTIL_PROG subvolume set-default $subvolid $SCRATCH_MNT >> $seqres.full 2>
|| _fail "couldn't set default"
$BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/newvol >> $seqres.full 2>&1
_scratch_unmount
_scratch_mount || _fail "mount should have succeeded"
_try_scratch_mount || _fail "mount should have succeeded"
echo "Silence is golden"
status=0 ; exit
+2 -2
View File
@@ -74,7 +74,7 @@ _scratch_unmount
# Convert it to btrfs, mount it, verify the data
$BTRFS_CONVERT_PROG $SCRATCH_DEV >> $seqres.full 2>&1 || \
_fail "btrfs-convert failed"
_scratch_mount || _fail "Could not mount new btrfs fs"
_try_scratch_mount || _fail "Could not mount new btrfs fs"
# (Ignore the symlinks which may be broken/nonexistent)
diff -r /lib/modules/`uname -r`/ $SCRATCH_MNT/`uname -r`/ 2>&1 | grep -vw "source\|build"
@@ -114,7 +114,7 @@ _scratch_unmount
# Convert it to btrfs, mount it and delete "ext2_saved"
$BTRFS_CONVERT_PROG $SCRATCH_DEV >> $seqres.full 2>&1 || \
_fail "btrfs-convert failed"
_scratch_mount || _fail "Could not mount new btrfs fs"
_try_scratch_mount || _fail "Could not mount new btrfs fs"
$BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/ext2_saved >> $seqres.full 2>&1 ||
_fail "failed to delete ext2_saved subvolume"
_scratch_unmount
+1 -1
View File
@@ -48,7 +48,7 @@ _require_btrfs_qgroup_report
rm -f $seqres.full
run_check _scratch_mkfs
run_check _scratch_mount
_scratch_mount
LIMIT_SIZE=$((10 * 1024 * 1024))
+1 -1
View File
@@ -54,7 +54,7 @@ run_check _scratch_mkfs "-b 1g --nodesize 4096"
# inode cache is saved in the FS tree itself for every
# individual FS tree,that affects the sizes reported by qgroup show
# so we need to explicitly turn it off to get consistent values.
run_check _scratch_mount "-o noinode_cache"
_scratch_mount "-o noinode_cache"
# -w ensures that the only ops are ones which cause write I/O
run_check $FSSTRESS_PROG -d $SCRATCH_MNT -w -p 5 -n 1000 \
+2 -2
View File
@@ -61,12 +61,12 @@ run_check _scratch_mkfs "--nodesize $NODESIZE"
# result.
# discard error output since we will check return value manually.
# also disable all compression, or output will mismatch with golden output
_scratch_mount "-o noinode_cache,compress=no,compress-force=no" 2> /dev/null
_try_scratch_mount "-o noinode_cache,compress=no,compress-force=no" 2> /dev/null
# Check for old kernel which doesn't support 'noinode_cache' mount option
if [ $? -ne 0 ]; then
support_noinode_cache="no"
run_check _scratch_mount
_scratch_mount
fi
_run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv1
+2 -2
View File
@@ -114,8 +114,8 @@ _scratch_unmount
mkfs_v2
echo "Trying to mount without free space tree"
_scratch_mount -o nospace_cache >/dev/null 2>&1 || echo "mount failed"
_scratch_mount -o space_cache=v1 >/dev/null 2>&1 || echo "mount failed"
_try_scratch_mount -o nospace_cache >/dev/null 2>&1 || echo "mount failed"
_try_scratch_mount -o space_cache=v1 >/dev/null 2>&1 || echo "mount failed"
mkfs_v2
echo "Mounting existing free space tree"

Some files were not shown because too many files have changed in this diff Show More