Fix test 049 so that it works with larger default log sizes
[xfstests-dev.git] / 019
1 #! /bin/sh
2 # XFS QA Test No. 019
3 #
4 # mkfs protofile 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 seqfull="$seq.full"
47 status=1        # failure is the default!
48 # get standard environment, filters and checks
49 . ./common.rc
50 . ./common.filter
51
52 _notrun "Retired until V1 directory code gets fixed up"
53
54 _cleanup()
55 {
56     echo "*** unmount"
57     umount $SCRATCH_MNT 2>/dev/null
58     rm -f $tmp.*
59 }
60 trap "_cleanup; exit \$status" 0 1 2 3 15
61
62 _full()
63 {
64     echo ""            >>$seqfull      
65     echo "*** $* ***"  >>$seqfull
66     echo ""            >>$seqfull
67 }
68
69 _filter_stat()
70 {
71     sed '
72         /^Access:/d;
73         /^Modify:/d;
74         /^Change:/d;
75         s/Device: *[0-9][0-9]*,[0-9][0-9]*/Device: <DEVICE>/;
76         s/Inode: *[0-9][0-9]*/Inode: <INODE>/;
77         s/Size: *[0-9][0-9]* *Filetype: Dir/Size: <DSIZE> Filetype: Dir/;
78     ' | tr -s ' '
79 }
80
81 # real QA test starts here
82
83 _require_scratch
84
85 protofile=$tmp.proto
86 tempfile=$tmp.file
87
88 echo fish >$tempfile
89 $here/src/devzero -b 2048 -n 2 $tempfile.2 -c -v 44
90
91 cat >$protofile <<EOF
92 DUMMY1
93 0 0
94 : root directory
95 d--777 3 1
96 : a directory
97 directory d--755 3 1 
98 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_0 ---755 3 1 $tempfile
99 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_1 ---755 3 1 $tempfile
100 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_2 ---755 3 1 $tempfile
101 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_3 ---755 3 1 $tempfile
102 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_4 ---755 3 1 $tempfile
103 $
104 : back in the root
105 setuid -u-666 0 0 $tempfile
106 setgid --g666 0 0 $tempfile
107 setugid -ug666 0 0 $tempfile
108 block_device b--012 3 1 161 162 
109 char_device c--345 3 1 177 178
110 pipe p--670 0 0
111 symlink l--123 0 0 bigfile
112 : a file we actually read
113 bigfile ---666 3 0 $tempfile.2
114 : done
115 $
116 EOF
117
118 if [ $? -ne 0 ]
119 then
120     _fail "failed to create test protofile"
121 fi
122
123 _verify_fs()
124 {
125         echo "*** create FS version $1"
126         VERSION="-n version=$1"
127
128         rm -f $seqfull
129         umount $SCRATCH_DEV >/dev/null 2>&1
130
131         _full "mkfs"
132         _scratch_mkfs_xfs $VERSION -p $protofile >>$seqfull 2>&1 \
133                 || _fail "mount failed"
134
135         echo "*** check FS"
136         _check_scratch_fs
137
138         echo "*** mount FS"
139         _full " mount"
140         _scratch_mount >>$seqfull 2>&1 \
141                 || _fail "mount failed"
142     
143         echo "*** verify FS"
144         (cd $SCRATCH_MNT ; find . | sort \
145                 | xargs $here/src/lstat64 | _filter_stat)
146         diff -q $SCRATCH_MNT/bigfile $tempfile.2 \
147                 || _fail "bigfile corrupted"
148     
149         echo "*** unmount FS"
150         _full "umount"
151         umount $SCRATCH_DEV >>$seqfull 2>&1 \
152                 || _fail "umount failed"
153             
154         echo "*** check FS"
155         _check_scratch_fs
156 }
157
158 _verify_fs 1
159 _verify_fs 2
160
161 echo "*** done"
162 rm $seqfull
163 status=0
164 exit