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