common/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify
[xfstests-dev.git] / tests / generic / 441
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017, Jeff Layton <jlayton@redhat.com>
4 #
5 # FS QA Test No. 441
6 #
7 # Open a file several times, write to it, fsync on all fds and make sure that
8 # they all return 0. Change the device to start throwing errors. Write again
9 # on all fds and fsync on all fds. Ensure that we get errors on all of them.
10 # Then fsync on all one last time and verify that all return 0.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1    # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -rf $tmp.* $testdir
25         _dmerror_cleanup
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31 . ./common/dmerror
32
33 # real QA test starts here
34 _supported_os Linux
35 _require_scratch
36 # This test uses "dm" without taking into account the data could be on
37 # realtime subvolume, thus the test will fail with rtinherit=1
38 _require_no_rtinherit
39
40 # Generally, we want to avoid journal errors on the extended testcase. Only
41 # unset the -s flag if we have a logdev
42 sflag='-s'
43 case $FSTYP in
44         btrfs)
45                 _notrun "btrfs has a specialized test for this"
46                 ;;
47         ext3|ext4|xfs)
48                 # Do the more thorough test if we have a logdev
49                 _has_logdev && sflag=''
50                 ;;
51         *)
52                 ;;
53 esac
54
55 _require_dm_target error
56 _require_test_program fsync-err
57 _require_test_program dmerror
58
59 rm -f $seqres.full
60
61 echo "Format and mount"
62 _scratch_mkfs > $seqres.full 2>&1
63 _dmerror_init
64 _dmerror_mount
65
66 _require_fs_space $SCRATCH_MNT 65536
67
68 testfile=$SCRATCH_MNT/fsync-err-test
69
70 echo "$here/src/fsync-err $sflag -d $here/src/dmerror $testfile" >> $seqres.full
71 $here/src/fsync-err $sflag -d $here/src/dmerror $testfile
72
73 # success, all done
74 _dmerror_load_working_table
75 _dmerror_unmount
76 _dmerror_cleanup
77
78 # fs may be corrupt after this -- attempt to repair it
79 _repair_scratch_fs >> $seqres.full
80
81 status=0
82 exit