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