2215b64db9a7fef9575ff810f5c8a2211da1ebac
[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_fs ext2 ext3 ext4 xfs
49 _supported_os Linux
50 _require_scratch
51
52 # Generally, we want to avoid journal errors in this test. Ensure that
53 # journalled fs' have a logdev.
54 if [ "$FSTYP" != "ext2" ]; then
55         _require_logdev
56 fi
57
58 _require_dm_target error
59 _require_test_program fsync-err
60 _require_test_program dmerror
61
62 rm -f $seqres.full
63
64 echo "Format and mount"
65 _scratch_mkfs > $seqres.full 2>&1
66 _dmerror_init
67 _dmerror_mount
68
69 _require_fs_space $SCRATCH_MNT 65536
70
71 testfile=$SCRATCH_MNT/fsync-err-test
72
73 $here/src/fsync-err -d $here/src/dmerror $testfile
74
75 # success, all done
76 _dmerror_load_working_table
77 _dmerror_unmount
78 _dmerror_cleanup
79
80 # fs may be corrupt after this -- attempt to repair it
81 _repair_scratch_fs >> $seqres.full
82
83 status=0
84 exit