xfs: Check for extent overflow when trivally adding a new extent
[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
42 # Create the test directory
43 mkdir ${TDIR}
44
45 # Set the test directory extsize
46 $XFS_IO_PROG -c "extsize ${EXTSIZE}" ${TDIR}
47
48 # Create a set of holey files
49 echo "generating ${NFILES} files"
50
51 for i in $(seq 0 ${NFILES}); do
52   $here/src/t_holes ${TDIR}/${i}
53 done
54
55 # Compare the files
56 echo "comparing files"
57 errcnt=0
58 j=0
59 for i in $(seq 0 ${NFILES}); do
60     let j=$i+1
61     while [ ${j} -lt ${NFILES} ] ; do
62         if ! cmp ${TDIR}/${i} ${TDIR}/${j} ; then
63             let errcnt=$errcnt+1
64         fi
65         let j=$j+1
66     done
67 done
68
69 echo "got ${errcnt} errors"
70
71 status=$errcnt
72 exit $status