xfstests: make install support common/ and tests/ dirs
[xfstests-dev.git] / tests / xfs / 012
1 #! /bin/bash
2 # FS QA Test No. 012
3 #
4 # holes
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2001 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 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=0        # success is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36     cd /
37     rm -f $tmp.*
38     rm -rf $testdir/holes.$$.*
39     _cleanup_testdir
40 }
41
42 _filesize()
43 {
44     ls -l $1 | $AWK_PROG '{print "    filesize = " $5}'
45 }
46
47 # get standard environment, filters and checks
48 . ./common/rc
49 . ./common/filter
50
51 _do_test()
52 {
53     _n="$1"
54     _param="$2"
55     _count="$3"
56     
57     failed=0
58     
59     out=$testdir/holes.$$.$_n
60     echo ""
61     echo "holes.$_n : $_param"
62     echo "-----------------------------------------------"
63     if  ! $here/src/holes $_param $out >$tmp.out
64     then
65         echo "    holes returned $? - see $seqres.full"
66         failed=1
67         status=1
68     fi
69         
70
71     if [ $failed -eq 0 ]
72     then        
73         # quick check - how many holes did we get?
74         count=`xfs_bmap $out | egrep -c ': hole'`
75         echo "    $count hole(s) detected"
76         # and how big was the file?
77         _filesize $out
78         
79         if [ $count -ne $_count ]
80         then
81             echo "    unexpected number of holes - see $seqres.full"
82             status=1
83             failed=1
84         fi
85     fi
86         
87     if [ $failed -eq 1 ]
88     then
89         echo "--------------------------------------"       >>$seqres.full
90         echo "$_n - output from holes:"                     >>$seqres.full
91         echo "--------------------------------------"       >>$seqres.full
92         cat $tmp.out                                        >>$seqres.full
93         echo "--------------------------------------"       >>$seqres.full
94         echo "$_n - output from bmap:"                      >>$seqres.full
95         echo "--------------------------------------"       >>$seqres.full
96         xfs_bmap -vvv $out                                  >>$seqres.full
97         echo "--------------------------------------"       >>$seqres.full
98         echo "$_n - output from ls -li:"                    >>$seqres.full
99         echo "--------------------------------------"       >>$seqres.full
100         ls -li $out                                         >>$seqres.full
101         status=1
102     fi
103 }
104
105 # real QA test starts here
106 _supported_fs xfs
107 _supported_os IRIX Linux
108
109 _setup_testdir
110
111 rm -f $seqres.full
112
113 # small & fairly dense
114 _do_test 1 "-l 40960000 -b 40960 -i 10 -c 1" 100
115
116 # big & sparse
117 _do_test 2 "-l 409600000 -b 40960 -i 1000 -c 1" 10
118
119 # no holes, but a very nasty way to write a file (lots of extents)
120 _do_test 3 "-l 40960000 -b 40960 -i 10 -c 10" 0
121
122 exit