mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
common: use mount/umount helpers everywhere
Replace every explicit mount/umount of scratch or test devices with helper functions. This allows the next patch to add in hooks to these functions in order to set up & tear down overlayfs on every mount/umount (also adds _test_unmount(), which didn't exist prior) [Eryu Guan rebased the patch agains latest master and replaced more mount/umount with helpers] Signed-off-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Eric Sandeen <esandeen@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
committed by
Dave Chinner
parent
4545386ca0
commit
27d077ec0b
+1
-1
@@ -233,7 +233,7 @@ _require_noattr2()
|
||||
{
|
||||
_scratch_mkfs_xfs > /dev/null 2>&1 \
|
||||
|| _fail "_scratch_mkfs_xfs failed on $SCRATCH_DEV"
|
||||
_mount -o noattr2 $SCRATCH_DEV > /dev/null 2>&1 \
|
||||
_scratch_mount -o noattr2 > /dev/null 2>&1 \
|
||||
|| _notrun "noattr2 mount option not supported on $SCRATCH_DEV"
|
||||
_scratch_unmount
|
||||
}
|
||||
|
||||
+1
-1
@@ -288,7 +288,7 @@ _cleanup()
|
||||
_stable_fs()
|
||||
{
|
||||
_saveddir=`pwd`; cd /
|
||||
umount $SCRATCH_MNT >>$seqres.full || _fail "unmount failed"
|
||||
_scratch_unmount >>$seqres.full || _fail "unmount failed"
|
||||
_scratch_mount >>$seqres.full || _fail "mount failed"
|
||||
cd $_saveddir
|
||||
}
|
||||
|
||||
+1
-1
@@ -225,5 +225,5 @@ _cleanup_streams_umount()
|
||||
{
|
||||
cd /
|
||||
rm -rf ${SCRATCH_MNT}/stream*
|
||||
umount $SCRATCH_DEV 2>/dev/null
|
||||
_scratch_unmount 2>/dev/null
|
||||
}
|
||||
|
||||
+3
-3
@@ -339,7 +339,7 @@ _create_log()
|
||||
|
||||
# unmount the FS
|
||||
_full "umount"
|
||||
umount $SCRATCH_DEV >>$seqres.full 2>&1
|
||||
_scratch_unmount >>$seqres.full 2>&1
|
||||
if [ $? -ne 0 ] ; then
|
||||
_echofull "umount failed"
|
||||
return 1
|
||||
@@ -370,7 +370,7 @@ _create_log_sync()
|
||||
|
||||
# unmount the FS
|
||||
_full "umount"
|
||||
umount $SCRATCH_DEV >>$seqres.full 2>&1
|
||||
_scratch_unmount >>$seqres.full 2>&1
|
||||
if [ $? -ne 0 ] ; then
|
||||
_echofull "umount failed"
|
||||
return 1
|
||||
@@ -482,7 +482,7 @@ _require_v2log()
|
||||
# check after unmount to see if it is clean
|
||||
# i.e. it is not a 6.5.25 buggy version checking kernel
|
||||
touch $SCRATCH_MNT/file
|
||||
umount $SCRATCH_DEV >>$seqres.full 2>&1
|
||||
_scratch_unmount >>$seqres.full 2>&1
|
||||
if _scratch_xfs_logprint -t | tee -a $seqres.full \
|
||||
| head | grep -q "<DIRTY>"; then
|
||||
_notrun "kernel does not support v2 logs"
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ _test_punch() {
|
||||
local filename=punch_test_file
|
||||
|
||||
cd /
|
||||
umount $SCRATCH_MNT >/dev/null 2>&1
|
||||
_scratch_unmount >/dev/null 2>&1
|
||||
|
||||
_scratch_mkfs_xfs -bsize=$blksize >/dev/null 2>&1 \
|
||||
|| _fail "mkfs failed"
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ _choose_prid()
|
||||
|
||||
_qmount()
|
||||
{
|
||||
umount $SCRATCH_DEV >/dev/null 2>&1
|
||||
_scratch_unmount >/dev/null 2>&1
|
||||
_scratch_mount || _fail "qmount failed"
|
||||
chmod ugo+rwx $SCRATCH_MNT
|
||||
}
|
||||
|
||||
@@ -270,9 +270,14 @@ _test_mount()
|
||||
_mount -t $FSTYP $TEST_OPTIONS $TEST_FS_MOUNT_OPTS $SELINUX_MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
|
||||
}
|
||||
|
||||
_test_unmount()
|
||||
{
|
||||
$UMOUNT_PROG $TEST_DEV
|
||||
}
|
||||
|
||||
_test_remount()
|
||||
{
|
||||
$UMOUNT_PROG $TEST_DEV
|
||||
_test_unmount
|
||||
_test_mount
|
||||
}
|
||||
|
||||
@@ -326,7 +331,7 @@ _setup_large_xfs_fs()
|
||||
$SCRATCH_MNT/.use_space 2>&1 > /dev/null
|
||||
export NUM_SPACE_FILES=1
|
||||
status=$?
|
||||
umount $SCRATCH_MNT
|
||||
_scratch_unmount
|
||||
if [ $status -ne 0 ]; then
|
||||
echo "large file prealloc failed"
|
||||
cat $tmp_dir/mnt.err >&2
|
||||
@@ -501,7 +506,7 @@ _setup_large_ext4_fs()
|
||||
fi
|
||||
export NUM_SPACE_FILES=$nfiles
|
||||
|
||||
umount $SCRATCH_MNT
|
||||
_scratch_unmount
|
||||
if [ $status -ne 0 ]; then
|
||||
echo "large file prealloc failed"
|
||||
cat $tmp_dir/mnt.err >&2
|
||||
@@ -1178,7 +1183,7 @@ _require_scratch_nocheck()
|
||||
exit 1
|
||||
fi
|
||||
# and then unmount it
|
||||
if ! $UMOUNT_PROG $SCRATCH_DEV
|
||||
if ! _scratch_unmount
|
||||
then
|
||||
echo "failed to unmount $SCRATCH_DEV"
|
||||
exit 1
|
||||
@@ -1422,7 +1427,7 @@ _require_xfs_crc()
|
||||
_scratch_mkfs_xfs -m crc=1 >/dev/null 2>&1
|
||||
_scratch_mount >/dev/null 2>&1 \
|
||||
|| _notrun "Kernel doesn't support crc feature"
|
||||
umount $SCRATCH_MNT
|
||||
_scratch_unmount
|
||||
}
|
||||
|
||||
# this test requires the ext4 kernel support crc feature on scratch device
|
||||
@@ -1433,7 +1438,7 @@ _require_scratch_ext4_crc()
|
||||
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 \
|
||||
|| _notrun "Kernel doesn't support metadata_csum feature"
|
||||
umount $SCRATCH_MNT
|
||||
_scratch_unmount
|
||||
}
|
||||
|
||||
# this test requires the xfs kernel support crc feature on scratch device
|
||||
@@ -1444,7 +1449,7 @@ _require_scratch_xfs_crc()
|
||||
_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"
|
||||
umount $SCRATCH_MNT
|
||||
_scratch_unmount
|
||||
}
|
||||
|
||||
# this test requires the bigalloc feature to be available in mkfs.ext4
|
||||
@@ -1462,7 +1467,7 @@ _require_ext4_bigalloc()
|
||||
$MKFS_EXT4_PROG -F -O bigalloc $SCRATCH_DEV 512m >/dev/null 2>&1
|
||||
_scratch_mount >/dev/null 2>&1 \
|
||||
|| _notrun "Ext4 kernel doesn't support bigalloc feature"
|
||||
umount $SCRATCH_MNT
|
||||
_scratch_unmount
|
||||
}
|
||||
|
||||
# this test requires the finobt feature to be available in mkfs.xfs
|
||||
@@ -1480,7 +1485,7 @@ _require_xfs_finobt()
|
||||
_scratch_mkfs_xfs -m crc=1,finobt=1 >/dev/null 2>&1
|
||||
_scratch_mount >/dev/null 2>&1 \
|
||||
|| _notrun "Kernel doesn't support finobt feature"
|
||||
umount $SCRATCH_MNT
|
||||
_scratch_unmount
|
||||
}
|
||||
|
||||
# this test requires xfs sysfs attribute support
|
||||
@@ -1508,7 +1513,7 @@ _require_xfs_sparse_inodes()
|
||||
_scratch_mkfs_xfs -m crc=1 -i sparse > /dev/null 2>&1
|
||||
_scratch_mount >/dev/null 2>&1 \
|
||||
|| _notrun "kernel does not support sparse inodes"
|
||||
umount $SCRATCH_MNT
|
||||
_scratch_unmount
|
||||
}
|
||||
|
||||
# this test requires that external log/realtime devices are not in use
|
||||
@@ -2824,7 +2829,7 @@ _require_meta_uuid()
|
||||
|
||||
_scratch_mount >/dev/null 2>&1 \
|
||||
|| _notrun "Kernel doesn't support meta_uuid feature"
|
||||
umount $SCRATCH_MNT
|
||||
_scratch_unmount
|
||||
}
|
||||
|
||||
_require_btrfs_dev_del_by_devid()
|
||||
|
||||
+2
-2
@@ -114,7 +114,7 @@ _check_repair()
|
||||
dd if=/bin/bash of=$SCRATCH_MNT/sh 2>&1 |_filter_dd
|
||||
sync
|
||||
rm -f $SCRATCH_MNT/sh
|
||||
umount $SCRATCH_MNT
|
||||
_scratch_unmount
|
||||
|
||||
_zero_position $value "$structure"
|
||||
_scratch_xfs_repair 2>&1 | _filter_repair
|
||||
@@ -127,7 +127,7 @@ _check_repair()
|
||||
POSIXLY_CORRECT=yes \
|
||||
dd if=$SCRATCH_MNT/sh of=/dev/null 2>&1 |_filter_dd #read
|
||||
rm -f $SCRATCH_MNT/sh #unlink
|
||||
umount $SCRATCH_MNT #umount
|
||||
_scratch_unmount #umount
|
||||
}
|
||||
|
||||
# make sure this script returns success
|
||||
|
||||
Reference in New Issue
Block a user