allow it to accept the text form of a file handle
[xfstests-dev.git] / 044
1 #! /bin/sh
2 # XFS QA Test No. 041
3 # $Id: 1.1 $
4 #
5 # external log uuid/format tests
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2000 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 "rm -f $tmp.*; exit \$status" 0 1 2 3 15
49
50 # get standard environment, filters and checks
51 . ./common.rc
52 . ./common.filter
53
54 # real QA test starts here
55
56 _require_logdev
57
58 _filter_logprint()
59 {
60         perl -ne '
61             s/data device: ([\w|\/]+)/data device: DDEV/;
62             s/log device: ([\w|\/]+) daddr: (\d+) length: (\d+)/log device: LDEV daddr: XXX length: XXX/;
63             s/log file: "([\w|\/]+)" daddr: (\d+) length: (\d+)/log device: LDEV daddr: XXX length: XXX/;
64             s/uuid: ([abcdef\d-]+)\s+format: (.+)/uuid: UUID format: FORMAT/;
65             s/skipped (\w+) zeroed blocks/skipped XXX zeroed blocks/;
66             print;
67         '
68 }
69
70 _check_mount()
71 {
72     echo "    *** mount (expect success)"
73     if ! mount -t xfs -o logdev=$SCRATCH_LOGDEV $SCRATCH_DEV $SCRATCH_MNT
74     then
75         echo "        !!! mount failed (expecting success)"
76         status=1
77         exit
78     fi
79
80     echo "    *** umount"
81     if ! umount $SCRATCH_DEV
82     then
83         echo "        !!! umount failed (expecting success)"
84         status=1
85         exit
86     fi
87 }
88
89 _check_no_mount()
90 {
91     echo "    *** mount (expect failure)"
92     if mount -t xfs -o logdev=$SCRATCH_LOGDEV $SCRATCH_DEV $SCRATCH_MNT >$tmp.err 2>&1
93     then
94         cat $tmp.err
95         echo "        !!! mount succeeded (expecting failure)"
96         status=1
97         exit
98     fi
99 }
100
101 _check_require_logdev()
102 {
103     echo "    *** mount without logdev (expect failure)"
104     if mount -t xfs $SCRATCH_DEV $SCRATCH_MNT >$tmp.err 2>&1
105     then
106         cat $tmp.err
107         echo "        !!! mount succeeded (expecting failure)"
108         status=1
109         exit
110     fi
111 }
112
113 _unexpected()
114 {
115     echo "        !!! unexpected XFS command failure"
116     status=1
117     exit
118 }
119
120
121 # real QA test starts here
122
123 _require_scratch
124
125 echo -e -n "\n\r*** XFS QA 044 - expect mount failure messages\n\r\n\r" >/dev/console
126
127 echo "*** mkfs"
128 mkfs_xfs -f -l logdev=$SCRATCH_LOGDEV,size=4096b $SCRATCH_DEV | _filter_mkfs 2>/dev/null
129 _check_mount
130 _check_require_logdev
131
132 echo "*** set uuid"
133 xfs_db -x $SCRATCH_DEV -l $SCRATCH_LOGDEV -c "uuid 02020202-0202-0202-0202-020202020202"
134 [ $? -ne 0 ] && _unexpected
135 _check_mount
136
137 echo "*** zero log"
138 $here/src/loggen -z 100 >$SCRATCH_LOGDEV
139 _check_mount
140
141 echo "*** write clean log"
142 $here/src/loggen -u 2 -f 1 -m 1 -z 100 >$SCRATCH_LOGDEV
143 _check_mount
144
145 echo "*** write clean log (different format)"
146 $here/src/loggen -u 2 -f 99 -m 1 -z 100 >$SCRATCH_LOGDEV
147 _check_mount
148
149 echo "*** write clean log (different uuid)"
150 $here/src/loggen -u 7 -m 1 -z 100 >$SCRATCH_LOGDEV
151 _check_no_mount
152
153 echo "*** write clean log (different uuid & format)"
154 $here/src/loggen -u 7 -f 99 -m 1 -z 100 >$SCRATCH_LOGDEV
155 _check_no_mount
156
157 echo "*** write dirty log"
158 $here/src/loggen -u 2 -e 1 -z 100 >$SCRATCH_LOGDEV
159 _check_mount
160
161 echo "*** write dirty log (different format)"
162 $here/src/loggen -u 2 -f 99 -e 1 -z 100 >$SCRATCH_LOGDEV
163 _check_no_mount
164
165 echo "*** write dirty log (irix style)"
166 $here/src/loggen -u 0 -f 0 -e 1 -z 100 >$SCRATCH_LOGDEV
167 _check_no_mount
168
169 echo "*** write large dirty log"
170 $here/src/loggen -u 2 -e 16000 -z 100 >$SCRATCH_LOGDEV
171 _check_mount
172
173 echo -e -n "\n\r*** XFS QA 044 - done\n\r\n\r" >/dev/console
174
175 status=0
176 # if error
177 exit