common/rc: factor out _scratch_xfs_[get|set]_sb_field
[xfstests-dev.git] / tests / xfs / 229
1 #! /bin/bash
2 # FS QA Test No. 221
3 #
4 # Check for file corruption when using the extent size hint on
5 # the normal data subvolume.
6 #
7 # http://oss.sgi.com/bugzilla/show_bug.cgi?id=874
8 #
9 # Based on a bug report and testcase from Geoffrey Wehrman <gwehrman@sgi.com>.
10 #
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2010 Christoph Hellwig.  All Rights Reserved.
13 # Copyright (c) 2010 Silicon Graphics, Inc.  All Rights Reserved.
14 #
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
18 #
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
27 #
28 #-----------------------------------------------------------------------
29 #
30
31 seq=`basename $0`
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 tmp=/tmp/$$
37 status=1        # failure is the default!
38
39 _cleanup()
40 {
41     rm -rf ${TDIR}
42 }
43
44 trap "_cleanup ; exit \$status" 0 1 2 3 15
45
46 # get standard environment, filters and checks
47 . ./common/rc
48
49 # real QA test starts here
50 _supported_fs xfs
51 _supported_os Linux
52 _require_test
53 _require_fs_space $TEST_DIR 3200000
54
55 TDIR="${TEST_DIR}/t_holes"
56 NFILES="10"
57 EXTSIZE="256k"
58
59 # Create the test directory
60 mkdir ${TDIR}
61
62 # Set the test directory extsize
63 $XFS_IO_PROG -c "extsize ${EXTSIZE}" ${TDIR}
64
65 # Create a set of holey files
66 echo "generating ${NFILES} files"
67
68 for i in $(seq 0 ${NFILES}); do
69   $here/src/t_holes ${TDIR}/${i}
70 done
71
72 # Compare the files
73 echo "comparing files"
74 errcnt=0
75 j=0
76 for i in $(seq 0 ${NFILES}); do
77     let j=$i+1
78     while [ ${j} -lt ${NFILES} ] ; do
79         if ! cmp ${TDIR}/${i} ${TDIR}/${j} ; then
80             let errcnt=$errcnt+1
81         fi
82         let j=$j+1
83     done
84 done
85
86 echo "got ${errcnt} errors"
87
88 status=$errcnt
89 exit $status