generic: add test for boundary in xfs_attr_shortform_verify
[xfstests-dev.git] / tests / generic / 311
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Fusion IO. All Rights Reserved.
4 #
5 # FS QA Test No. 311
6 #
7 # Run various fsync tests with dm flakey in freeze() mode and non freeze()
8 # mode. The idea is that we do random writes and randomly fsync and verify that
9 # after a fsync() followed by a freeze()+failure or just failure that the file
10 # is correct.  We remount the file system after the failure so that the file
11 # system can do whatever cleanup it needs to and md5sum the file to make sure
12 # it matches hat it was before the failure.  We also fsck to make sure the file
13 # system is consistent.
14 #
15 # The fsync tester just random writes into prealloc or not, and then fsync()s
16 # randomly or sync()'s randomly and then fsync()'s before exit.  There are a few
17 # tests that were handcrafted to reproduce bugs in btrfs, so it's also a
18 # regression test of sorts.
19 #
20 seq=`basename $0`
21 seqres=$RESULT_DIR/$seq
22 echo "QA output created by $seq"
23
24 here=`pwd`
25 status=1        # failure is the default!
26
27 _cleanup()
28 {
29         _cleanup_flakey
30 }
31 trap "_cleanup; exit \$status" 0 1 2 3 15
32
33 # get standard environment, filters and checks
34 . ./common/rc
35 . ./common/filter
36 . ./common/dmflakey
37
38 # real QA test starts here
39 _supported_fs generic
40 _supported_os Linux
41 _require_scratch_nocheck
42 _require_odirect
43 _require_dm_target flakey
44
45 # xfs_io is not required for this test, but it's the best way to verify
46 # the test system supports fallocate() for allocation
47 _require_xfs_io_command "falloc"
48
49 _require_test_program "fsync-tester"
50
51 rm -f $seqres.full
52 SEED=1
53 testfile=$SCRATCH_MNT/$seq.fsync
54
55 _run_test()
56 {
57         # _run_test <testnum> <0 - buffered | 1 - O_DIRECT>
58         test_num=$1
59
60         direct_opt=""
61         [ $2 -eq 1 ] && direct_opt="-d"
62
63         $here/src/fsync-tester -s $SEED -t $test_num $direct_opt $testfile
64         [ $? -ne 0 ] && _fatal "fsync tester exited abnormally"
65
66         _md5_checksum $testfile
67         _load_flakey_table $FLAKEY_DROP_WRITES $lockfs
68         _unmount_flakey
69
70         #Ok mount so that any recovery that needs to happen is done
71         _load_flakey_table $FLAKEY_ALLOW_WRITES
72         _mount_flakey
73         _md5_checksum $testfile
74
75         #Unmount and fsck to make sure we got a valid fs after replay
76         _unmount_flakey
77         _check_scratch_fs $FLAKEY_DEV
78         [ $? -ne 0 ] && _fatal "fsck failed"
79
80         _mount_flakey
81 }
82
83 _scratch_mkfs >> $seqres.full 2>&1
84 _require_metadata_journaling $SCRATCH_DEV
85
86 # Create a basic flakey device that will never error out
87 _init_flakey
88 _mount_flakey
89
90 buffered=0
91 direct=1
92
93 for i in $(seq 1 20); do
94         lockfs=1
95         SEED=$i
96         echo "Running test $i buffered, normal suspend"
97         _run_test $i $buffered
98         echo "Running test $i direct, normal suspend"
99         _run_test $i $direct
100
101         lockfs=0
102         echo "Running test $i buffered, nolockfs"
103         _run_test $i $buffered
104         echo "Running test $i direct, nolockfs"
105         _run_test $i $direct
106 done
107
108 status=0
109 exit