Ensure we do not oversubscribe freespace for AIO stress test.
[xfstests-dev.git] / 044
1 #! /bin/sh
2 # FS QA Test No. 044
3 #
4 # external log uuid/format tests (TODO - version 2 log format)
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8
9 # This program is free software; you can redistribute it and/or modify it
10 # under the terms of version 2 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, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17 # Further, this software is distributed without any warranty that it is
18 # free of the rightful claim of any third person regarding infringement
19 # or the like.  Any license provided herein, whether implied or
20 # otherwise, applies only to this software file.  Patent licenses, if
21 # any, provided herein do not apply to combinations of this program with
22 # other software, or any other product whatsoever.
23
24 # You should have received a copy of the GNU General Public License along
25 # with this program; if not, write the Free Software Foundation, Inc., 59
26 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
27
28 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
29 # Mountain View, CA  94043, or:
30
31 # http://www.sgi.com 
32
33 # For further information regarding this notice, see: 
34
35 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
36 #-----------------------------------------------------------------------
37 #
38 # creator
39 owner=dxm@sgi.com
40
41 seq=`basename $0`
42 echo "QA output created by $seq"
43
44 here=`pwd`
45 tmp=/tmp/$$
46 status=1        # failure is the default!
47 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
48
49 # get standard environment, filters and checks
50 . ./common.rc
51 . ./common.filter
52
53 # real QA test starts here
54 _supported_fs xfs
55 _supported_os Linux
56
57 _require_logdev
58
59 _filter_logprint()
60 {
61         perl -ne '
62             s/data device: ([\w|\/.-]+)/data device: DDEV/;
63             s/log device: ([\w|\/.-]+) daddr: (\d+) length: (\d+)/log device: LDEV daddr: XXX length: XXX/;
64             s/log file: "([\w|\/.-]+)" daddr: (\d+) length: (\d+)/log device: LDEV daddr: XXX length: XXX/;
65             s/uuid: ([abcdef\d-]+)\s+format: (.+)/uuid: UUID format: FORMAT/;
66             s/skipped (\w+) zeroed blocks/skipped XXX zeroed blocks/;
67             print;
68         '
69 }
70
71 _check_mount()
72 {
73     echo "    *** mount (expect success)"
74     if ! _scratch_mount
75     then
76         echo "        !!! mount failed (expecting success)"
77         status=1
78         exit
79     fi
80
81     echo "    *** umount"
82     if ! umount $SCRATCH_DEV
83     then
84         echo "        !!! umount failed (expecting success)"
85         status=1
86         exit
87     fi
88 }
89
90 _check_no_mount()
91 {
92     echo "    *** mount (expect failure)"
93     if _scratch_mount >$tmp.err 2>&1
94     then
95         cat $tmp.err
96         echo "        !!! mount succeeded (expecting failure)"
97         status=1
98         exit
99     fi
100 }
101
102 _check_require_logdev()
103 {
104     echo "    *** mount without logdev (expect failure)"
105     if mount -t xfs $SCRATCH_DEV $SCRATCH_MNT >$tmp.err 2>&1
106     then
107         cat $tmp.err
108         echo "        !!! mount succeeded (expecting failure)"
109         status=1
110         exit
111     fi
112 }
113
114 _unexpected()
115 {
116     echo "        !!! unexpected XFS command failure"
117     status=1
118     exit
119 }
120
121
122 # real QA test starts here
123
124 _require_scratch
125
126 echo -e -n "\n\r*** XFS QA 044 - expect mount failure messages\n\r\n\r" >/dev/console
127
128 echo "*** mkfs"
129
130 # this test only works for version 1 logs currently
131 lversion=1
132 lsize=16777216
133 _scratch_mkfs_xfs -lsize=$lsize,version=$lversion >$tmp.mkfs0 2>&1
134 [ $? -ne 0 ] && \
135     _notrun "Cannot mkfs for this test using MKFS_OPTIONS specified"
136 _filter_mkfs <$tmp.mkfs0 2>$tmp.mkfs1
137 . $tmp.mkfs1
138 [ $lversion -ne 1 ] && \
139     _notrun "Cannot run this test yet using MKFS_OPTIONS specified"
140
141 _check_mount
142 _check_require_logdev
143
144 echo "*** set uuid"
145 xfs_db -x $SCRATCH_DEV -l $SCRATCH_LOGDEV -c "uuid 02020202-0202-0202-0202-020202020202"
146 [ $? -ne 0 ] && _unexpected
147 _check_mount
148
149 echo "*** zero log"
150 $here/src/loggen -z 100 >$SCRATCH_LOGDEV
151 _check_mount
152
153 echo "*** write clean log"
154 $here/src/loggen -u 2 -f 1 -m 1 -z 100 >$SCRATCH_LOGDEV
155 _check_mount
156
157 echo "*** write clean log (different format)"
158 $here/src/loggen -u 2 -f 99 -m 1 -z 100 >$SCRATCH_LOGDEV
159 _check_mount
160
161 echo "*** write clean log (different uuid)"
162 $here/src/loggen -u 7 -m 1 -z 100 >$SCRATCH_LOGDEV
163 _check_no_mount
164
165 echo "*** write clean log (different uuid & format)"
166 $here/src/loggen -u 7 -f 99 -m 1 -z 100 >$SCRATCH_LOGDEV
167 _check_no_mount
168
169 echo "*** write dirty log"
170 $here/src/loggen -u 2 -e 1 -z 100 >$SCRATCH_LOGDEV
171 _check_mount
172
173 echo "*** write dirty log (different format)"
174 $here/src/loggen -u 2 -f 99 -e 1 -z 100 >$SCRATCH_LOGDEV
175 _check_no_mount
176
177 echo "*** write dirty log (irix style)"
178 $here/src/loggen -u 0 -f 0 -e 1 -z 100 >$SCRATCH_LOGDEV
179 _check_no_mount
180
181 echo "*** write large dirty log"
182 $here/src/loggen -u 2 -e 16000 -z 100 >$SCRATCH_LOGDEV
183 _check_mount
184
185 echo -e -n "\n\r*** XFS QA 044 - done\n\r\n\r" >/dev/console
186
187 status=0
188 # if error
189 exit