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