misc: tag all tests that examine crash recovery in a loop
[xfstests-dev.git] / tests / generic / 019
index 7a019ad6e48eb9798f9a151cc95e9be220199dca..db56dac1ed1e3125e706da694d569531fb994841 100755 (executable)
@@ -1,47 +1,25 @@
 #! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+#
 # FSQA Test No. generic/019
 #
 # Run fsstress and fio(dio/aio and mmap) and simulate disk failure
 # check filesystem consistency at the end.
 #
-#-----------------------------------------------------------------------
-# (c) 2013 Dmitry Monakhov
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-#
-#-----------------------------------------------------------------------
-#
-
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
+. ./common/preamble
+_begin_fstest aio dangerous enospc rw stress recoveryloop
 
-here=`pwd`
-tmp=/tmp/$$
 fio_config=$tmp.fio
-status=1       # failure is the default!
 
-# get standard environment, filters and checks
-. ./common/rc
+# Import common functions.
 . ./common/filter
 _supported_fs generic
-_supported_os Linux
-_need_to_be_root
 _require_scratch
+_require_block_device $SCRATCH_DEV
 _require_fail_make_request
 
-SCRATCH_BDEV=`_short_dev $SCRATCH_DEV`
+SYSFS_BDEV=`_sysfs_dev $SCRATCH_DEV`
 
 allow_fail_make_request()
 {
@@ -61,32 +39,32 @@ disallow_fail_make_request()
 start_fail_scratch_dev()
 {
     echo "Force SCRATCH_DEV device failure"
-    echo " echo 1 > /sys/block/$SCRATCH_BDEV/make-it-fail" >> $seqres.full
-    echo 1 > /sys/block/$SCRATCH_BDEV/make-it-fail
-
+    echo " echo 1 > $SYSFS_BDEV/make-it-fail" >> $seqres.full
+    echo 1 > $SYSFS_BDEV/make-it-fail
 }
 
 stop_fail_scratch_dev()
 {
     echo "Make SCRATCH_DEV device operable again"
-    echo " echo 0 > /sys/block/$SCRATCH_BDEV/make-it-fail" >> $seqres.full
-    echo 0 > /sys/block/$SCRATCH_BDEV/make-it-fail
-
+    echo " echo 0 > $SYSFS_BDEV/make-it-fail" >> $seqres.full
+    echo 0 > $SYSFS_BDEV/make-it-fail
 }
 
+# Override the default cleanup function.
 _cleanup()
 {
-    poweron_scratch_dev
     disallow_fail_make_request
     rm -f $tmp.*
 }
-trap "_cleanup; exit \$status" 1 2 3 15
 
 RUN_TIME=$((20+10*$TIME_FACTOR))
 NUM_JOBS=$((4*LOAD_FACTOR))
 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
 FILE_SIZE=$((BLK_DEV_SIZE * 512))
 
+# Don't fail the test just because fio or fsstress dump cores
+ulimit -c 0
+
 cat >$fio_config <<EOF
 ###########
 # $seq test's fio activity
@@ -157,29 +135,27 @@ _workout()
            >> $seqres.full 2>&1 && \
            _fail "failed: still able to perform integrity fsync on $SCRATCH_MNT"
 
-       kill $fs_pid
+       kill $fs_pid &> /dev/null
        wait $fs_pid
        wait $fio_pid
 
        # We expect that broken FS still can be umounted
-       run_check umount $SCRATCH_DEV
+       run_check _scratch_unmount
        # Once filesystem was umounted no one is able to write to block device
        # It is now safe to bring device back to normal state
        stop_fail_scratch_dev
 
        # In order to check that filesystem is able to recover journal on mount(2)
        # perform mount/umount, after that all errors should be fixed
-       run_check _scratch_mount
+       _scratch_mount
        run_check _scratch_unmount
-       _check_scratch_fs
 }
 
 # real QA test starts here
 
 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
-_scratch_mount || _fail "mount failed"
+_scratch_mount
 allow_fail_make_request
 _workout
 status=$?
-disallow_fail_make_request
 exit