xfs: force file creation to the data device for certain layout tests
[xfstests-dev.git] / tests / xfs / 229
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2010 Christoph Hellwig.  All Rights Reserved.
4 # Copyright (c) 2010 Silicon Graphics, Inc.  All Rights Reserved.
5 #
6 # FS QA Test No. 221
7 #
8 # Check for file corruption when using the extent size hint on
9 # the normal data subvolume.
10 #
11 # http://oss.sgi.com/bugzilla/show_bug.cgi?id=874
12 #
13 # Based on a bug report and testcase from Geoffrey Wehrman <gwehrman@sgi.com>.
14 #
15 seq=`basename $0`
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
18
19 here=`pwd`
20 tmp=/tmp/$$
21 status=1        # failure is the default!
22
23 _cleanup()
24 {
25     rm -rf ${TDIR}
26 }
27
28 trap "_cleanup ; exit \$status" 0 1 2 3 15
29
30 # get standard environment, filters and checks
31 . ./common/rc
32
33 # real QA test starts here
34 _supported_fs xfs
35 _require_test
36 _require_fs_space $TEST_DIR 3200000
37
38 TDIR="${TEST_DIR}/t_holes"
39 NFILES="10"
40 EXTSIZE="256k"
41 _xfs_force_bdev data $TEST_DIR
42
43 # Create the test directory
44 mkdir ${TDIR}
45
46 # Set the test directory extsize
47 $XFS_IO_PROG -c "extsize ${EXTSIZE}" ${TDIR}
48
49 # Create a set of holey files
50 echo "generating ${NFILES} files"
51
52 for i in $(seq 0 ${NFILES}); do
53   $here/src/t_holes ${TDIR}/${i}
54 done
55
56 # Compare the files
57 echo "comparing files"
58 errcnt=0
59 j=0
60 for i in $(seq 0 ${NFILES}); do
61     let j=$i+1
62     while [ ${j} -lt ${NFILES} ] ; do
63         if ! cmp ${TDIR}/${i} ${TDIR}/${j} ; then
64             let errcnt=$errcnt+1
65         fi
66         let j=$j+1
67     done
68 done
69
70 echo "got ${errcnt} errors"
71
72 status=$errcnt
73 exit $status