xfstests: add local.config example
[xfstests-dev.git] / 044
1 #! /bin/bash
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 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
12 #
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
16 #
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 #
26 #-----------------------------------------------------------------------
27 #
28 # creator
29 owner=dxm@sgi.com
30
31 seq=`basename $0`
32 echo "QA output created by $seq"
33
34 here=`pwd`
35 tmp=/tmp/$$
36 status=1        # failure is the default!
37 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
38
39 # get standard environment, filters and checks
40 . ./common.rc
41 . ./common.filter
42
43 # real QA test starts here
44 _supported_fs xfs
45 _supported_os Linux
46
47 _require_logdev
48
49 _filter_logprint()
50 {
51         perl -ne '
52             s/data device: ([\w|\/.-]+)/data device: DDEV/;
53             s/log device: ([\w|\/.-]+) daddr: (\d+) length: (\d+)/log device: LDEV daddr: XXX length: XXX/;
54             s/log file: "([\w|\/.-]+)" daddr: (\d+) length: (\d+)/log device: LDEV daddr: XXX length: XXX/;
55             s/uuid: ([abcdef\d-]+)\s+format: (.+)/uuid: UUID format: FORMAT/;
56             s/skipped (\w+) zeroed blocks/skipped XXX zeroed blocks/;
57             print;
58         '
59 }
60
61 _check_mount()
62 {
63     echo "    *** mount (expect success)"
64     if ! _scratch_mount
65     then
66         echo "        !!! mount failed (expecting success)"
67         status=1
68         exit
69     fi
70
71     echo "    *** umount"
72     if ! umount $SCRATCH_DEV
73     then
74         echo "        !!! umount failed (expecting success)"
75         status=1
76         exit
77     fi
78 }
79
80 _check_no_mount()
81 {
82     echo "    *** mount (expect failure)"
83     if _scratch_mount >$tmp.err 2>&1
84     then
85         cat $tmp.err
86         echo "        !!! mount succeeded (expecting failure)"
87         status=1
88         exit
89     fi
90 }
91
92 _check_require_logdev()
93 {
94     echo "    *** mount without logdev (expect failure)"
95     if mount -t xfs $SCRATCH_DEV $SCRATCH_MNT >$tmp.err 2>&1
96     then
97         cat $tmp.err
98         echo "        !!! mount succeeded (expecting failure)"
99         status=1
100         exit
101     fi
102 }
103
104 _unexpected()
105 {
106     echo "        !!! unexpected XFS command failure"
107     status=1
108     exit
109 }
110
111
112 # real QA test starts here
113
114 _require_scratch
115
116 echo "*** mkfs"
117
118 # this test only works for version 1 logs currently
119 lversion=1
120 lsize=16777216
121 _scratch_mkfs_xfs -lsize=$lsize,version=$lversion >$tmp.mkfs0 2>&1
122 [ $? -ne 0 ] && \
123     _notrun "Cannot mkfs for this test using MKFS_OPTIONS specified"
124 _filter_mkfs <$tmp.mkfs0 2>$tmp.mkfs1
125 . $tmp.mkfs1
126 [ $lversion -ne 1 ] && \
127     _notrun "Cannot run this test yet using MKFS_OPTIONS specified"
128
129 [ $here/src/loggen ] || _notrun "loggen not built, skipping test"
130
131 _check_mount
132 _check_require_logdev
133
134 echo "*** set uuid"
135 xfs_db -x $SCRATCH_DEV -l $SCRATCH_LOGDEV -c "uuid 02020202-0202-0202-0202-020202020202"
136 [ $? -ne 0 ] && _unexpected
137 _check_mount
138
139 echo "*** zero log"
140 $here/src/loggen -z 100 >$SCRATCH_LOGDEV
141 _check_mount
142
143 echo "*** write clean log"
144 $here/src/loggen -u 2 -f 1 -m 1 -z 100 >$SCRATCH_LOGDEV
145 _check_mount
146
147 echo "*** write clean log (different format)"
148 $here/src/loggen -u 2 -f 99 -m 1 -z 100 >$SCRATCH_LOGDEV
149 _check_mount
150
151 echo "*** write clean log (different uuid)"
152 $here/src/loggen -u 7 -m 1 -z 100 >$SCRATCH_LOGDEV
153 _check_no_mount
154
155 echo "*** write clean log (different uuid & format)"
156 $here/src/loggen -u 7 -f 99 -m 1 -z 100 >$SCRATCH_LOGDEV
157 _check_no_mount
158
159 echo "*** write dirty log"
160 $here/src/loggen -u 2 -e 1 -z 100 >$SCRATCH_LOGDEV
161 _check_mount
162
163 echo "*** write dirty log (different format)"
164 $here/src/loggen -u 2 -f 99 -e 1 -z 100 >$SCRATCH_LOGDEV
165 _check_no_mount
166
167 echo "*** write dirty log (irix style)"
168 $here/src/loggen -u 0 -f 0 -e 1 -z 100 >$SCRATCH_LOGDEV
169 _check_no_mount
170
171 echo "*** write large dirty log"
172 $here/src/loggen -u 2 -e 16000 -z 100 >$SCRATCH_LOGDEV
173 _check_mount
174
175 echo -e -n "\n\r*** XFS QA 044 - done\n\r\n\r" >/dev/console
176
177 status=0
178 # if error
179 exit