Updates to QA scrdiff script to keep package configure macros in sync.
[xfstests-dev.git] / 009
1 #! /bin/sh
2 # XFS QA Test No. 009
3 # $Id: 1.1 $
4 #
5 # alloc test
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
9
10 # This program is free software; you can redistribute it and/or modify it
11 # under the terms of version 2 of the GNU General Public License as
12 # published by the Free Software Foundation.
13
14 # This program is distributed in the hope that it would be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18 # Further, this software is distributed without any warranty that it is
19 # free of the rightful claim of any third person regarding infringement
20 # or the like.  Any license provided herein, whether implied or
21 # otherwise, applies only to this software file.  Patent licenses, if
22 # any, provided herein do not apply to combinations of this program with
23 # other software, or any other product whatsoever.
24
25 # You should have received a copy of the GNU General Public License along
26 # with this program; if not, write the Free Software Foundation, Inc., 59
27 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
28
29 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
30 # Mountain View, CA  94043, or:
31
32 # http://www.sgi.com 
33
34 # For further information regarding this notice, see: 
35
36 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
37 #-----------------------------------------------------------------------
38 #
39 # creator
40 owner=dxm@sgi.com
41
42 seq=`basename $0`
43 echo "QA output created by $seq"
44
45 here=`pwd`
46 tmp=/tmp/$$
47 status=1        # failure is the default!
48 trap "_cleanup; exit \$status" 0 1 2 3 15
49 # This isn't really related to fs block size, it's just what
50 # alloc uses for the "block" unit in it's input parameters...
51 bsize=4096
52
53 _cleanup()
54 {
55     echo "*** unmount"
56     umount $SCRATCH_MNT
57 }
58
59 _block_filter()
60 {
61    sed \
62         -e 's/[0-9][0-9]*\.\.[0-9][0-9]*/BLOCKRANGE/g' \
63         -e "s/blocksize $bsize/blocksize BSIZE/g"
64 }
65
66 _init()
67 {
68     echo "*** mkfs"
69     if ! mkfs_xfs $SCRATCH_DEV >$tmp.out 2>&1
70     then
71         cat $tmp.out
72         echo "failed to mkfs $SCRATCH_DEV"
73         exit 1
74     fi
75
76     echo "*** mount"
77     if ! mount $SCRATCH_DEV $SCRATCH_MNT -t xfs
78     then
79         echo "failed to mount $SCRATCH_DEV"
80         exit 1
81     fi
82 }
83
84 _filesize()
85 {
86     ls -l $1 | $AWK_PROG '{print "filesize = " $5}'
87 }
88
89 # get standard environment, filters and checks
90 . ./common.rc
91 . ./common.filter
92
93 # real QA test starts here
94
95 _require_scratch
96
97 _init
98 out=$SCRATCH_MNT/$$.tmp
99
100 # since we're using a clean FS here, we make some assumptions
101 # about availability of contiguous blocks
102
103 # also interesting to note is that ALLOC == FREE. seriously.
104 # the _length is ignored_ in irix. the file is allocated up
105 # to the specified offset, and zero filled if previously
106 # unallocated. the file is truncated at the specified point.
107
108 echo "*** test 1 - reservations cleared on O_TRUNC"
109 rm -f $out
110 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
111 r 0 1000b
112 m
113 EOF
114 _filesize $out
115
116 cat <<EOF | src/alloc -n -b $bsize -f $out -t | _block_filter
117 m
118 EOF
119 _filesize $out
120
121 echo "*** test 2 - reserve & filesize"
122 rm -f $out
123 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
124 r 0 1000b
125 EOF
126
127 _filesize $out
128
129 echo "*** test 3 - alloc & filesize"
130 rm -f $out
131 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
132 a 1000b
133 EOF
134
135 _filesize $out
136
137 echo "*** test 4 - allocations cleared on O_TRUNC"
138 rm -f $out
139 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
140 a 1000b
141 EOF
142 _filesize $out
143
144 cat <<EOF | src/alloc -n -b $bsize -f $out -t | _block_filter
145 m
146 EOF
147 _filesize $out
148
149 echo "*** test 5 - reserve / unreserve"
150 rm -f $out
151 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
152 r 0 100b
153 u 100b 500b
154 m
155 u 900b 200b
156 m
157 EOF
158
159 echo "*** test 6 - reserve adjacent"
160 rm -f $out
161 cat <<EOF | src/alloc -t -n -b $bsize -f $out | _block_filter
162 r 0 100b
163 r 100b 100b
164 m
165 EOF
166
167 echo "*** test 7 - alloc"
168 rm -f $out
169 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
170 a 1000b
171 m
172 a 2000b
173 m
174 EOF
175
176 _filesize $out
177
178 echo "*** test 8 - alloc & truncate"
179 rm -f $out
180 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
181 a 1000b
182 m
183 t 500b
184 m
185 EOF
186
187 _filesize $out
188
189 echo "*** test 9 - reserve & truncate"
190 rm -f $out
191 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
192 r 0 1000b
193 m
194 t 500b
195 m
196 EOF
197
198 _filesize $out
199
200
201 status=0
202 exit