Update xfstests control scripts to allow multiple kernel versions and multiple archit...
[xfstests-dev.git] / 018
1 #! /bin/sh
2 # XFS QA Test No. 018
3 #
4 # xfs_logprint test
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=0        # success is the default!
47
48 # get standard environment, filters and checks
49 . ./common.rc
50 . ./common.filter
51
52 _cleanup()
53 {
54     rm -f $tmp.*
55     echo "*** unmount"
56     umount $SCRATCH_MNT 2>/dev/null
57 }
58 trap "_cleanup; exit \$status" 0 1 2 3 15
59
60 _full()
61 {
62     echo ""            >>$seq.full      
63     echo "*** $* ***"  >>$seq.full
64     echo ""            >>$seq.full
65 }
66
67 _filter_logprint()
68 {
69     sed '
70         s/data device: 0x[0-9a-f][0-9a-f]*/data device: <DEVICE>/;
71         s/log device: 0x[0-9a-f][0-9a-f]*/log device: <DEVICE>/;
72         s/log file: \".*\"/log device: <DEVICE>/;
73         s/daddr: [0-9][0-9]*/daddr: <DADDR>/;
74         s/length: [0-9][0-9]*/length: <LENGTH>/;
75         s/length: [0-9][0-9]*/length: <LENGTH>/;
76         s/^cycle num overwrites: .*$/cycle num overwrites: <TIDS>/;
77         s/tid: [0-9a-f][0-9a-f]*/tid: <TID>/;
78         s/tid:0x[0-9a-f][0-9a-f]*/tid:<TID>/;
79         s/q:0x[0-9a-f][0-9a-f]*/q:<Q>/;
80         s/a:0x[0-9a-f][0-9a-f]*/a:<A>/g;
81         s/blkno:0x[0-9a-f][0-9a-f]*/blkno:<BLKNO>/g;
82         s/blkno: [0-9][0-9]* (0x[0-9a-f]*)/blkno: <BLKNO> (<BLKNO>)/g;
83         s/blkno: [0-9][0-9]*/blkno: <BLKNO>/g;
84         s/boff: [0-9][0-9]*/boff: <BOFF>/g;
85         s/len: *[0-9][0-9]*/len:<LEN>/g;
86         s/skipped [0-9][0-9]* zeroed blocks/skipped <COUNT> zeroed blocks/;
87         s/atime:[0-9a-fx]*  *mtime:[0-9a-fx]*  *ctime:[0-9a-fx]*/atime:<TIME>  mtime:<TIME>  ctime:<TIME>/;
88         s/atime 0x[0-9a-f]* mtime 0x[0-9a-f]* ctime 0x[0-9a-f]*/atime <TIME>  mtime <TIME>  ctime <TIME>/;
89         s/block [0-9][0-9]*/block <BLOCK>/;
90         s/icount: *[0-9][0-9]*  *ifree: *[0-9][0-9]*  *fdblks: *[0-9][0-9]*  *frext: *[0-9][0-9]*/icount:<COUNT> ifree:<FREE> fdblks:<BLOCKS> frext:<COUNT>/;
91         s/sunit: *[0-9][0-9]*  *swidth: *[0-9][0-9]*/sunit:<SUNIT> swidth:<SWIDTH>/;
92         s/1st: *[0-9][0-9]*  *last: *[0-9][0-9]*  *cnt: *[0-9][0-9]*  *freeblks: *[0-9][0-9]*  *longest: *[0-9][0-9]*/1st:<NUM> last:<NUM> cnt:<COUNT> freeblks:<COUNT> longest:<NUM>/;
93         s/^uuid: *[0-9a-f-][0-9a-f-]* *format: *.*$/uuid: <UUID> format: <FORMAT>/;
94         /flushiter:/d;
95     ' | _fix_malloc
96 }
97
98 _setup_log()
99 {
100     rm -f $seq.log
101     _full "clean_log : xfs_logprint"
102
103     _scratch_xfs_logprint -t       | tee -a $seq.full \
104         | head | grep -q "<CLEAN>" || _fail "DIRTY LOG"
105
106     echo "### xfs_logprint output ###"                          >>$seq.log
107     _scratch_xfs_logprint 2>&1 | _filter_logprint               >>$seq.log
108     echo "### xfs_logprint -t -i -s 0 output ###"               >>$seq.log
109     _scratch_xfs_logprint -t -i -s 0 2>&1 | _filter_logprint    >>$seq.log
110     echo "### xfs_logprint -t -b -s 0 output ###"               >>$seq.log
111     _scratch_xfs_logprint -t -b -s 0 2>&1 | _filter_logprint    >>$seq.log
112
113     echo $seq.log
114 }
115
116 # find the comparison file, depending on which form of quota is
117 # enabled as this often influences how the test output appears.
118 # [NB: SCRATCH_DEV must be mounted for this to work]
119
120 _setup_log_out()
121 {
122     if src/feature -U $SCRATCH_DEV
123     then
124         if src/feature -G $SCRATCH_DEV
125         then
126             echo $seq.ugquota
127         else
128             echo $seq.usrquota
129         fi
130     elif src/feature -G $SCRATCH_DEV
131     then
132         echo $seq.grpquota
133     else
134         echo $seq.noquota
135     fi
136 }
137
138
139 # real QA test starts here
140
141 _require_scratch
142
143 echo "*** init FS"
144
145 umount $SCRATCH_DEV >/dev/null 2>&1
146
147 _full "mkfs"
148
149 _scratch_mkfs_xfs -lsize=2000b >$tmp.mkfs0 2>&1
150 [ $? -ne 0 ] && \
151     _notrun "Cannot mkfs for this test using MKFS_OPTIONS specified"
152 _filter_mkfs <$tmp.mkfs0 2>$tmp.mkfs
153 source $tmp.mkfs
154 [ $dbsize -eq 4096 ] \
155     || _notrun "Logprint test, tailored to 4K blocks ($dbsize in use)"
156 [ $isize -eq 256 ] \
157     || _notrun "Logprint test, tailored to 256b inodes ($isize in use)"
158 [ $lversion -eq 1 ]  \
159     || _notrun "Logprint test, tailored to v1 log format (v$lversion in use)"
160
161 rm -f $seq.log $seq.full
162
163 _full " mount"
164 _scratch_mount >>$seq.full 2>&1 \
165     || _fail "mount failed"
166
167 base=`_setup_log_out`
168
169 # generate some log traffic - but not too much - life gets a little
170 # more complicated if the log wraps around. This traffic is
171 # pretty much arbitary, but could probably be made better than this.
172
173 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
174     
175 _full "umount"
176 umount $SCRATCH_DEV >>$seq.full 2>&1 \
177     || _fail "umount failed"
178
179 mine=`_setup_log`
180
181 echo "*** compare logprint"
182
183 if ! diff $mine $base >/dev/null; then
184     echo "FAILED: logprint output $mine differs to $base"
185     exit 1
186 fi
187
188 rm $seq.full
189 exit