Test to reproduce PV951636: project quotas not updated if a file is mv'd into that...
[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 }
33
34 # get standard environment, filters and checks
35 . ./common.rc
36 . ./common.filter
37
38 _do_test()
39 {
40     _n="$1"
41     _holes="$2"
42     _param="$3"
43
44     out=$testdir/randholes.$$.$_n
45     echo ""
46     echo "randholes.$_n : $_param" | _filter
47     echo "------------------------------------------"
48     if $here/src/randholes $_param $out >$tmp.out
49     then
50         # only check if we're not allocating in huge chunks (extsz flag)
51         if _test_inode_flag extsize $out || _test_inode_flag realtime $out
52         then
53                 echo "holes is in range"
54         else
55                 # quick check - how many holes did we get?
56                 count=`xfs_bmap $out | egrep -c ': hole'`
57                 # blocks can end up adjacent, therefore number of holes varies
58                 _within_tolerance "holes" $count $_holes 10% -v
59         fi
60     else
61         echo "    randholes returned $? - see $seq.out.full"
62         echo "--------------------------------------"       >>$here/$seq.out.full
63         echo "$_n - output from randholes:"                 >>$here/$seq.out.full
64         echo "--------------------------------------"       >>$here/$seq.out.full
65         cat $tmp.out                                        >>$here/$seq.out.full
66         echo "--------------------------------------"       >>$here/$seq.out.full
67         echo "$_n - output from bmap:"                      >>$here/$seq.out.full
68         echo "--------------------------------------"       >>$here/$seq.out.full
69         xfs_bmap -vvv $out                                  >>$here/$seq.out.full
70         status=1
71     fi
72 }
73
74 # real QA test starts here
75 _supported_fs xfs
76 _supported_os IRIX Linux
77
78 _setup_testdir
79
80 rm -f $here/$seq.out.full
81
82 _do_test 1 50 "-l 5000000 -c 50 -b $pgsize"
83 _do_test 2 100 "-l 10000000 -c 100 -b $pgsize"
84 _do_test 3 100 "-l 10000000 -c 100 -b 512"   # test partial pages
85
86 # rinse, lather, repeat for direct IO
87 _do_test 4 50 "-d -l 5000000 -c 50 -b $pgsize"
88 _do_test 5 100 "-d -l 10000000 -c 100 -b $pgsize"
89 # note: direct IO requires page aligned IO
90
91 # todo: realtime.
92
93 # success, all done
94 exit