d0d8bd8eb0fbeb933979bc6a9ff4a344ee1f906e
[xfstests-dev.git] / tests / xfs / 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
29 seq=`basename $0`
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
36
37 # get standard environment, filters and checks
38 . ./common.rc
39 . ./common.filter
40
41 # real QA test starts here
42 _supported_fs xfs
43 _supported_os Linux
44
45 _require_logdev
46
47 _filter_logprint()
48 {
49         perl -ne '
50             s/data device: ([\w|\/.-]+)/data device: DDEV/;
51             s/log device: ([\w|\/.-]+) daddr: (\d+) length: (\d+)/log device: LDEV daddr: XXX length: XXX/;
52             s/log file: "([\w|\/.-]+)" daddr: (\d+) length: (\d+)/log device: LDEV daddr: XXX length: XXX/;
53             s/uuid: ([abcdef\d-]+)\s+format: (.+)/uuid: UUID format: FORMAT/;
54             s/skipped (\w+) zeroed blocks/skipped XXX zeroed blocks/;
55             print;
56         '
57 }
58
59 _check_mount()
60 {
61     echo "    *** mount (expect success)"
62     if ! _scratch_mount
63     then
64         echo "        !!! mount failed (expecting success)"
65         status=1
66         exit
67     fi
68
69     echo "    *** umount"
70     if ! umount $SCRATCH_DEV
71     then
72         echo "        !!! umount failed (expecting success)"
73         status=1
74         exit
75     fi
76 }
77
78 _check_no_mount()
79 {
80     echo "    *** mount (expect failure)"
81     if _scratch_mount >$tmp.err 2>&1
82     then
83         cat $tmp.err
84         echo "        !!! mount succeeded (expecting failure)"
85         status=1
86         exit
87     fi
88 }
89
90 _check_require_logdev()
91 {
92     echo "    *** mount without logdev (expect failure)"
93     if mount -t xfs $SCRATCH_DEV $SCRATCH_MNT >$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 _unexpected()
103 {
104     echo "        !!! unexpected XFS command failure"
105     status=1
106     exit
107 }
108
109
110 # real QA test starts here
111
112 _require_scratch
113
114 echo "*** mkfs"
115
116 # this test only works for version 1 logs currently
117 lversion=1
118 lsize=16777216
119 _scratch_mkfs_xfs -lsize=$lsize,version=$lversion >$tmp.mkfs0 2>&1
120 [ $? -ne 0 ] && \
121     _notrun "Cannot mkfs for this test using MKFS_OPTIONS specified"
122 _filter_mkfs <$tmp.mkfs0 2>$tmp.mkfs1
123 . $tmp.mkfs1
124 [ $lversion -ne 1 ] && \
125     _notrun "Cannot run this test yet using MKFS_OPTIONS specified"
126
127 [ $here/src/loggen ] || _notrun "loggen not built, skipping test"
128
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