Make "new" script insert appropriate license on tests
[xfstests-dev.git] / 008
1 #! /bin/sh
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 # creator
25 owner=dxm@sgi.com
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=0        # success is the default!
33 pgsize=`$here/src/feature -s`
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38     rm -f $tmp.*
39     rm -rf $testdir/randholes.$$.*
40     _cleanup_testdir
41 }
42
43 _filter()
44 {
45     sed -e "s/-b $pgsize/-b PGSIZE/g" \
46         -e "s/-l .* -c/-l FSIZE -c/g"
47 }
48
49 # get standard environment, filters and checks
50 . ./common.rc
51 . ./common.filter
52
53 _do_test()
54 {
55     _n="$1"
56     _holes="$2"
57     _param="$3"
58
59     out=$testdir/randholes.$$.$_n
60     echo ""
61     echo "randholes.$_n : $_param" | _filter
62     echo "------------------------------------------"
63     if $here/src/randholes $_param $out >$tmp.out
64     then
65         # only check if we're not allocating in huge chunks (extsz flag)
66         if _test_inode_flag extsize $out || _test_inode_flag realtime $out
67         then
68                 echo "holes is in range"
69         else
70                 # quick check - how many holes did we get?
71                 count=`xfs_bmap $out | egrep -c ': hole'`
72                 # blocks can end up adjacent, therefore number of holes varies
73                 _within_tolerance "holes" $count $_holes 10% -v
74         fi
75     else
76         echo "    randholes returned $? - see $seq.out.full"
77         echo "--------------------------------------"       >>$here/$seq.out.full
78         echo "$_n - output from randholes:"                 >>$here/$seq.out.full
79         echo "--------------------------------------"       >>$here/$seq.out.full
80         cat $tmp.out                                        >>$here/$seq.out.full
81         echo "--------------------------------------"       >>$here/$seq.out.full
82         echo "$_n - output from bmap:"                      >>$here/$seq.out.full
83         echo "--------------------------------------"       >>$here/$seq.out.full
84         xfs_bmap -vvv $out                                  >>$here/$seq.out.full
85         status=1
86     fi
87 }
88
89 # real QA test starts here
90 _supported_fs xfs
91 _supported_os IRIX Linux
92
93 _setup_testdir
94
95 rm -f $here/$seq.out.full
96
97 # Note on special numbers here.
98 #
99 # We are trying to create roughly 50 or 100 holes in a file
100 # using random writes. Assuming a good distribution of 50 writes
101 # in a file, the file only needs to be 3-4x the size of the write
102 # size muliplied by the number of writes. Hence we use 200 * pgsize
103 # for files we want 50 holes in and 400 * pgsize for files we want
104 # 100 holes in. This keeps the runtime down as low as possible.
105 #
106 _do_test 1 50 "-l `expr 200 \* $pgsize` -c 50 -b $pgsize"
107 _do_test 2 100 "-l `expr 400 \* $pgsize` -c 100 -b $pgsize"
108 _do_test 3 100 "-l `expr 400 \* $pgsize` -c 100 -b 512"   # test partial pages
109
110 # rinse, lather, repeat for direct IO
111 _do_test 4 50 "-d -l `expr 200 \* $pgsize` -c 50 -b $pgsize"
112 _do_test 5 100 "-d -l `expr 400 \* $pgsize` -c 100 -b $pgsize"
113 # note: direct IO requires page aligned IO
114
115 # todo: realtime.
116
117 # success, all done
118 exit