read/write/trunc events are managed region events--print a warning if
[xfstests-dev.git] / 018
1 #! /bin/sh
2 # XFS QA Test No. 018
3 # $Id: 1.1 $
4 #
5 # xfs_logprint test
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=0        # success is the default!
48
49 # get standard environment, filters and checks
50 . ./common.rc
51 . ./common.filter
52
53 _cleanup()
54 {
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 _clean_log()
68 {
69     _full "clean_log : xfs_logprint"
70     xfs_logprint -t $1                     | tee -a $seq.full \
71         | head | grep -q "<CLEAN>" || _fail "DIRTY LOG"
72 }
73
74 _filter_logprint()
75 {
76     sed '
77         s/data device: 0x[0-9a-f][0-9a-f]*/data device: <DEVICE>/;
78         s/log device: 0x[0-9a-f][0-9a-f]*/log device: <DEVICE>/;
79         s/daddr: [0-9][0-9]*/daddr: <DADDR>/;
80         s/length: [0-9][0-9]*/length: <LENGTH>/;
81         s/length: [0-9][0-9]*/length: <LENGTH>/;
82         s/^cycle num overwrites: .*$/cycle num overwrites: <TIDS>/;
83         s/tid: [0-9a-f][0-9a-f]*/tid: <TID>/;
84         s/tid:0x[0-9a-f][0-9a-f]*/tid:<TID>/;
85         s/q:0x[0-9a-f][0-9a-f]*/q:<Q>/;
86         s/a:0x[0-9a-f][0-9a-f]*/a:<A>/g;
87         s/blkno:0x[0-9a-f][0-9a-f]*/blkno:<BLKNO>/g;
88         s/blkno: [0-9][0-9]* (0x[0-9a-f]*)/blkno: <BLKNO> (<BLKNO>)/g;
89         s/blkno: [0-9][0-9]*/blkno: <BLKNO>/g;
90         s/boff: [0-9][0-9]*/boff: <BOFF>/g;
91         s/len: *[0-9][0-9]*/len:<LEN>/g;
92         s/skipped [0-9][0-9]* zeroed blocks/skipped <COUNT> zeroed blocks/;
93         s/atime:[0-9a-fx]*  *mtime:[0-9a-fx]*  *ctime:[0-9a-fx]*/atime:<TIME>  mtime:<TIME>  ctime:<TIME>/;
94         s/atime 0x[0-9a-f]* mtime 0x[0-9a-f]* ctime 0x[0-9a-f]*/atime <TIME>  mtime <TIME>  ctime <TIME>/;
95         s/block [0-9][0-9]*/block <BLOCK>/;
96         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>/;
97         s/sunit: *[0-9][0-9]*  *swidth: *[0-9][0-9]*/sunit:<SUNIT> swidth:<SWIDTH>/;
98         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>/;
99         s/^uuid: *[0-9a-f-][0-9a-f-]* *format: *.*$/uuid: <UUID> format: <FORMAT>/;
100     '
101
102 }
103
104 _check_log()
105 {
106     _clean_log $SCRATCH_DEV
107     echo "### xfs_logprint output ###"
108     xfs_logprint $SCRATCH_DEV 2>&1 | _filter_logprint
109     echo "### xfs_logprint -t -i -s 0 output ###"
110     xfs_logprint -t -i -s 0 $SCRATCH_DEV 2>&1 | _filter_logprint
111     echo "### xfs_logprint -t -b -s 0 output ###"
112     xfs_logprint -t -b -s 0 $SCRATCH_DEV 2>&1 | _filter_logprint
113 }
114
115 # real QA test starts here
116
117 _require_scratch
118
119 echo "*** init FS"
120
121 rm -f $seq.out $seq.full
122 umount $SCRATCH_DEV >/dev/null 2>&1
123
124 _full "mkfs"
125 mkfs -t xfs -f -lsize=2000b $SCRATCH_DEV    >>$seq.full 2>&1 \
126     || _fail "mkfs failed"
127 _full " mount"
128 mount -t xfs $SCRATCH_DEV $SCRATCH_MNT      >>$seq.full 2>&1 \
129     || _fail "mount failed"
130
131 _setup_seq_out
132
133 # generate some log traffic - but not too much - life gets a little
134 # more complicated if the log wraps around. This traffic is
135 # pretty much arbitary, but could probably be made better than this.
136
137 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
138     
139 _full "umount"
140 umount $SCRATCH_DEV >>$seq.full 2>&1 \
141     || _fail "umount failed"
142
143 _check_log
144
145 rm $seq.full
146 exit