0dee9f505e12d6d383d2063d0a046dc666cc91dd
[xfstests-dev.git] / 008
1 #! /bin/bash
2 # FS QA Test No. 008
3 #
4 # randholes test
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=0        # success is the default!
31 pgsize=`$here/src/feature -s`
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36     rm -f $tmp.*
37     rm -rf $testdir/randholes.$$.*
38     _cleanup_testdir
39 }
40
41 _filter()
42 {
43     sed -e "s/-b $pgsize/-b PGSIZE/g" \
44         -e "s/-l .* -c/-l FSIZE -c/g"
45 }
46
47 # get standard environment, filters and checks
48 . ./common.rc
49 . ./common.filter
50
51 _do_test()
52 {
53     _n="$1"
54     _holes="$2"
55     _param="$3"
56
57     out=$testdir/randholes.$$.$_n
58     echo ""
59     echo "randholes.$_n : $_param" | _filter
60     echo "------------------------------------------"
61     if $here/src/randholes $_param $out >$tmp.out
62     then
63         # only check if we're not allocating in huge chunks (extsz flag)
64         if _test_inode_flag extsize $out || _test_inode_flag realtime $out
65         then
66                 echo "holes is in range"
67         else
68                 # quick check - how many holes did we get?
69                 count=`xfs_bmap $out | egrep -c ': hole'`
70                 # blocks can end up adjacent, therefore number of holes varies
71                 _within_tolerance "holes" $count $_holes 10% -v
72         fi
73     else
74         echo "    randholes returned $? - see $seq.out.full"
75         echo "--------------------------------------"       >>$here/$seq.out.full
76         echo "$_n - output from randholes:"                 >>$here/$seq.out.full
77         echo "--------------------------------------"       >>$here/$seq.out.full
78         cat $tmp.out                                        >>$here/$seq.out.full
79         echo "--------------------------------------"       >>$here/$seq.out.full
80         echo "$_n - output from bmap:"                      >>$here/$seq.out.full
81         echo "--------------------------------------"       >>$here/$seq.out.full
82         xfs_bmap -vvv $out                                  >>$here/$seq.out.full
83         status=1
84     fi
85 }
86
87 # real QA test starts here
88 _supported_fs xfs
89 _supported_os IRIX Linux
90
91 _setup_testdir
92
93 rm -f $here/$seq.out.full
94
95 # Note on special numbers here.
96 #
97 # We are trying to create roughly 50 or 100 holes in a file
98 # using random writes. Assuming a good distribution of 50 writes
99 # in a file, the file only needs to be 3-4x the size of the write
100 # size muliplied by the number of writes. Hence we use 200 * pgsize
101 # for files we want 50 holes in and 400 * pgsize for files we want
102 # 100 holes in. This keeps the runtime down as low as possible.
103 #
104 _do_test 1 50 "-l `expr 200 \* $pgsize` -c 50 -b $pgsize"
105 _do_test 2 100 "-l `expr 400 \* $pgsize` -c 100 -b $pgsize"
106 _do_test 3 100 "-l `expr 400 \* $pgsize` -c 100 -b 512"   # test partial pages
107
108 # rinse, lather, repeat for direct IO
109 _do_test 4 50 "-d -l `expr 200 \* $pgsize` -c 50 -b $pgsize"
110 _do_test 5 100 "-d -l `expr 400 \* $pgsize` -c 100 -b $pgsize"
111 # note: direct IO requires page aligned IO
112
113 # todo: realtime.
114
115 # success, all done
116 exit