8e46baa400e40a339beeefb2fa6be17e785292fc
[xfstests-dev.git] / 085
1 #! /bin/sh
2 # XFS QA Test No. 085
3 #
4 # To test log replay by shutdown of file system
5 # This is the first simple initial test to ensure that
6 # the goingdown ioctl is working and recovery of
7 # create transactions is working.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
11
12 # This program is free software; you can redistribute it and/or modify it
13 # under the terms of version 2 of the GNU General Public License as
14 # published by the Free Software Foundation.
15
16 # This program is distributed in the hope that it would be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20 # Further, this software is distributed without any warranty that it is
21 # free of the rightful claim of any third person regarding infringement
22 # or the like.  Any license provided herein, whether implied or
23 # otherwise, applies only to this software file.  Patent licenses, if
24 # any, provided herein do not apply to combinations of this program with
25 # other software, or any other product whatsoever.
26
27 # You should have received a copy of the GNU General Public License along
28 # with this program; if not, write the Free Software Foundation, Inc., 59
29 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
30
31 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
32 # Mountain View, CA  94043, or:
33
34 # http://www.sgi.com 
35
36 # For further information regarding this notice, see: 
37
38 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
39 #-----------------------------------------------------------------------
40 #
41 # creator
42 owner=tes@melbourne.sgi.com
43
44 seq=`basename $0`
45 echo "QA output created by $seq"
46
47 here=`pwd`
48 tmp=/tmp/$$
49 status=1        # failure is the default!
50 trap "_cleanup; exit \$status" 0 1 2 3 15
51
52 # get standard environment, filters and checks
53 . ./common.rc
54 . ./common.filter
55
56 # real QA test starts here
57
58 _do_logprint()
59 {
60     xfs_logprint -t $SCRATCH_DEV | tee -a $seq.full >$tmp.logprint
61     if grep -q "<DIRTY>" $tmp.logprint; then
62         echo "dirty log"
63     fi
64     if grep -q "<CLEAN>" $tmp.logprint; then
65         echo "clean log"
66     fi
67 }
68
69 _cleanup()
70 {
71     rm -f $tmp.*
72     kill $pid
73 }
74
75 rm -f $seq.full
76 rm -f $tmp.log
77
78 tail -f /var/log/messages >$tmp.log &
79 pid=$!
80 cp $tmp.log $tmp.log.orig # note the original log
81
82 _require_scratch
83
84 echo "mkfs"
85 _scratch_mkfs_xfs >>$seq.full 2>&1 \
86     || _fail "mkfs scratch failed"
87
88 echo "mount"
89 _scratch_mount >>$seq.full 2>&1 \
90     || _fail "mount failed: $MOUNT_OPTIONS"
91
92 echo "touch files"
93 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
94
95 echo "godown"
96 src/godown -v -f $SCRATCH_MNT >> $seq.full
97
98 echo "unmount"
99 umount $SCRATCH_MNT
100
101 echo "logprint after going down..."
102 _do_logprint
103
104 # curious if FS consistent at start
105 if false; then
106     if /usr/sbin/xfs_check $SCRATCH_DEV; then
107        echo "*** checked ok ***"
108     fi
109 fi
110
111 echo "mount with replay"
112 _scratch_mount $mnt >>$seq.full 2>&1 \
113     || _fail "mount failed: $mnt $MOUNT_OPTIONS"
114
115 sleep 2
116
117 # compare with what has now been added to the log
118 comm -13 $tmp.log.orig $tmp.log >$tmp.comm
119 echo "$tmp.comm" >>$seq.full
120 cat $tmp.comm >>$seq.full
121
122 echo "check syslog for recovery..." 
123 grep recovery $tmp.comm |\
124 sed -e 's/.*Start/Start/' -e 's/system:.*/system/' \
125     -e 's/.*End/End/'
126
127 echo "ls SCRATCH_MNT"
128 ls $SCRATCH_MNT
129
130 echo "unmount"
131 umount $SCRATCH_MNT
132
133 echo "logprint after mount and replay..."
134 _do_logprint
135
136 if _check_scratch_fs; then
137     echo "filesystem is checked ok"
138 else
139     echo "filesystem is NOT ok"
140 fi
141
142 # success, all done
143 status=0
144 exit