075d87723ca1e06a6df4bf213ecde1ad3f48b9fd
[xfstests-dev.git] / tests / generic / 441
1 #! /bin/bash
2 # FS QA Test No. 441
3 #
4 # Open a file several times, write to it, fsync on all fds and make sure that
5 # they all return 0. Change the device to start throwing errors. Write again
6 # on all fds and fsync on all fds. Ensure that we get errors on all of them.
7 # Then fsync on all one last time and verify that all return 0.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2017, Jeff Layton <jlayton@redhat.com>
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1    # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37         cd /
38         rm -rf $tmp.* $testdir
39         _dmerror_cleanup
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45 . ./common/dmerror
46
47 # real QA test starts here
48 _supported_os Linux
49 _require_scratch
50
51 # Generally, we want to avoid journal errors on the extended testcase. Only
52 # unset the -s flag if we have a logdev
53 sflag='-s'
54 case $FSTYP in
55         btrfs)
56                 _notrun "btrfs has a specialized test for this"
57                 ;;
58         ext3|ext4|xfs)
59                 # Do the more thorough test if we have a logdev
60                 _has_logdev && sflag=''
61                 ;;
62         *)
63                 ;;
64 esac
65
66 _require_dm_target error
67 _require_test_program fsync-err
68 _require_test_program dmerror
69
70 rm -f $seqres.full
71
72 echo "Format and mount"
73 _scratch_mkfs > $seqres.full 2>&1
74 _dmerror_init
75 _dmerror_mount
76
77 _require_fs_space $SCRATCH_MNT 65536
78
79 testfile=$SCRATCH_MNT/fsync-err-test
80
81 echo "$here/src/fsync-err $sflag -d $here/src/dmerror $testfile" >> $seqres.full
82 $here/src/fsync-err $sflag -d $here/src/dmerror $testfile
83
84 # success, all done
85 _dmerror_load_working_table
86 _dmerror_unmount
87 _dmerror_cleanup
88
89 # fs may be corrupt after this -- attempt to repair it
90 _repair_scratch_fs >> $seqres.full
91
92 status=0
93 exit