xfstests: move generic tests out of top level dir
[xfstests-dev.git] / 201
1 #! /bin/bash
2 # FS QA Test No. 201
3 #
4 # Test out the infamous xfs_btree_delrec corruption.
5 #
6 # Only happens on 32-bit kernels without CONFIG_LBD, but it should be harmless
7 # to run this everywhere.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2009 Christoph Hellwig.
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
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33
34 do_pwrite()
35 {
36         offset=`expr $1 \* 512`
37         end=`expr $2 \* 512`
38         length=`expr $end - $offset`
39
40         xfs_io -d -f $file -c "pwrite $offset $length" >/dev/null
41 }
42
43
44
45 _cleanup()
46 {
47         umount $SCRATCH_MNT
48 }
49 trap "_cleanup; exit \$status" 0 1 2 3 15
50
51 # get standard environment, filters and checks
52 . ./common.rc
53 . ./common.filter
54
55 # real QA test starts here
56 _supported_fs xfs
57 _supported_os Linux
58
59 file=$SCRATCH_MNT/f
60
61 _require_scratch
62
63 _scratch_mkfs_xfs >/dev/null 2>&1
64 _scratch_mount
65
66 # Create a fragmented file
67 do_pwrite 30792 31039
68 do_pwrite 30320 30791
69 do_pwrite 29688 30319
70 do_pwrite 29536 29687
71 do_pwrite 27216 29535
72 do_pwrite 24368 27215
73 do_pwrite 21616 24367
74 do_pwrite 20608 21615
75 do_pwrite 19680 20607
76 do_pwrite 19232 19679
77 do_pwrite 17840 19231
78 do_pwrite 16928 17839
79 do_pwrite 15168 16927
80 do_pwrite 14048 15167
81 do_pwrite 12152 14047
82 do_pwrite 11344 12151
83 do_pwrite 8792 11343
84 do_pwrite 6456 8791
85 do_pwrite 5000 6455
86 do_pwrite 1728 4999
87 do_pwrite 0 1727
88
89 sync
90 sync
91
92 # and truncate it again
93 > $SCRATCH_MNT/bigfile
94
95 # success, all done
96 echo "*** done"
97 rm -f $seq.full
98 status=0