Fix symlink detection in userspace Makefiles
[xfstests-dev.git] / 009
1 #! /bin/sh
2 # FS QA Test No. 009
3 #
4 # XFS allocator test (preallocation - allocp, resvsp ,etc)
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=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20 # This isn't really related to fs block size, it's just what
21 # alloc uses for the "block" unit in it's input parameters...
22 bsize=4096
23
24 _cleanup()
25 {
26     echo "*** unmount"
27     umount $SCRATCH_MNT
28 }
29
30 _block_filter()
31 {
32    sed \
33         -e 's/[0-9][0-9]*\.\.[0-9][0-9]*/BLOCKRANGE/g' \
34         -e "s/blocksize $bsize/blocksize BSIZE/g"
35 }
36
37 _init()
38 {
39     echo "*** mkfs"
40     if ! _scratch_mkfs_xfs >$tmp.out 2>&1
41     then
42         cat $tmp.out
43         echo "failed to mkfs $SCRATCH_DEV"
44         exit 1
45     fi
46
47     echo "*** mount"
48     if ! _scratch_mount
49     then
50         echo "failed to mount $SCRATCH_DEV"
51         exit 1
52     fi
53 }
54
55 _filesize()
56 {
57     ls -l $1 | $AWK_PROG '{print "filesize = " $5}'
58 }
59
60 # get standard environment, filters and checks
61 . ./common.rc
62 . ./common.filter
63
64 # real QA test starts here
65 _supported_fs xfs
66 _supported_os IRIX Linux
67
68 _require_scratch
69
70 _init
71 out=$SCRATCH_MNT/$$.tmp
72
73 # since we're using a clean FS here, we make some assumptions
74 # about availability of contiguous blocks
75
76 # also interesting to note is that ALLOC == FREE. seriously.
77 # the _length is ignored_ in irix. the file is allocated up
78 # to the specified offset, and zero filled if previously
79 # unallocated. the file is truncated at the specified point.
80
81 echo "*** test 1 - reservations cleared on O_TRUNC"
82 rm -f $out
83 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
84 r 0 1000b
85 m
86 EOF
87 _filesize $out
88
89 cat <<EOF | src/alloc -n -b $bsize -f $out -t | _block_filter
90 m
91 EOF
92 _filesize $out
93
94 echo "*** test 2 - reserve & filesize"
95 rm -f $out
96 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
97 r 0 1000b
98 EOF
99
100 _filesize $out
101
102 echo "*** test 3 - alloc & filesize"
103 rm -f $out
104 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
105 a 1000b
106 EOF
107
108 _filesize $out
109
110 echo "*** test 4 - allocations cleared on O_TRUNC"
111 rm -f $out
112 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
113 a 1000b
114 EOF
115 _filesize $out
116
117 cat <<EOF | src/alloc -n -b $bsize -f $out -t | _block_filter
118 m
119 EOF
120 _filesize $out
121
122 echo "*** test 5 - reserve / unreserve"
123 rm -f $out
124 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
125 r 0 100b
126 u 100b 500b
127 m
128 u 900b 200b
129 m
130 EOF
131
132 echo "*** test 6 - reserve adjacent"
133 rm -f $out
134 cat <<EOF | src/alloc -t -n -b $bsize -f $out | _block_filter
135 r 0 100b
136 r 100b 100b
137 m
138 EOF
139
140 echo "*** test 7 - alloc"
141 rm -f $out
142 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
143 a 1000b
144 m
145 a 2000b
146 m
147 EOF
148
149 _filesize $out
150
151 echo "*** test 8 - alloc & truncate"
152 rm -f $out
153 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
154 a 1000b
155 m
156 t 500b
157 m
158 EOF
159
160 _filesize $out
161
162 echo "*** test 9 - reserve & truncate"
163 rm -f $out
164 cat <<EOF | src/alloc -n -b $bsize -f $out | _block_filter
165 r 0 1000b
166 m
167 t 500b
168 m
169 EOF
170
171 _filesize $out
172
173
174 status=0
175 exit