common/fuzzy: if the fuzz verb is random, keep fuzzing until we get a new value
[xfstests-dev.git] / common / dmerror
index 5d2c1b68bcc09c040a82d547f0cb5654f8628035..238baa213b1f09cdc4719247be5d6e7fd309ab29 100644 (file)
 #
 # common functions for setting up and tearing down a dmerror device
 
-_dmerror_init()
+echo $MOUNT_OPTIONS | grep -q dax
+if [ $? -eq 0 ]; then
+       _notrun "Cannot run tests with DAX on dmerror devices"
+fi
+
+_dmerror_setup()
 {
        local dm_backing_dev=$SCRATCH_DEV
 
-       $DMSETUP_PROG remove error-test > /dev/null 2>&1
-
        local blk_dev_size=`blockdev --getsz $dm_backing_dev`
 
        DMERROR_DEV='/dev/mapper/error-test'
 
        DMLINEAR_TABLE="0 $blk_dev_size linear $dm_backing_dev 0"
 
-       $DMSETUP_PROG create error-test --table "$DMLINEAR_TABLE" || \
-               _fatal "failed to create dm linear device"
-
        DMERROR_TABLE="0 $blk_dev_size error $dm_backing_dev 0"
 }
 
-_dmerror_mount_options()
+_dmerror_init()
 {
-       echo `_common_dev_mount_options $*` $DMERROR_DEV $SCRATCH_MNT
+       _dmerror_setup
+       $DMSETUP_PROG remove error-test > /dev/null 2>&1
+       $DMSETUP_PROG create error-test --table "$DMLINEAR_TABLE" || \
+               _fatal "failed to create dm linear device"
 }
 
 _dmerror_mount()
 {
-       _mount -t $FSTYP `_dmerror_mount_options $*`
+       _scratch_options mount
+       $MOUNT_PROG -t $FSTYP `_common_dev_mount_options $*` $SCRATCH_OPTIONS \
+               $DMERROR_DEV $SCRATCH_MNT
 }
 
 _dmerror_unmount()
@@ -63,7 +68,12 @@ _dmerror_cleanup()
 _dmerror_load_error_table()
 {
        suspend_opt="--nolockfs"
-       [ $# -gt 1 ] && [ $2 -eq 1 ] && suspend_opt=""
+
+       if [ "$1" = "lockfs" ]; then
+               suspend_opt=""
+       elif [ -n "$*" ]; then
+               suspend_opt="$*"
+       fi
 
        $DMSETUP_PROG suspend $suspend_opt error-test
        [ $? -ne 0 ] && _fail  "dmsetup suspend failed"
@@ -78,7 +88,12 @@ _dmerror_load_error_table()
 _dmerror_load_working_table()
 {
        suspend_opt="--nolockfs"
-       [ $# -gt 1 ] && [ $2 -eq 1 ] && suspend_opt=""
+
+       if [ "$1" = "lockfs" ]; then
+               suspend_opt=""
+       elif [ -n "$*" ]; then
+               suspend_opt="$*"
+       fi
 
        $DMSETUP_PROG suspend $suspend_opt error-test
        [ $? -ne 0 ] && _fail  "dmsetup suspend failed"