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