Added machine cocky to common.config
[xfstests-dev.git] / 019
1 #! /bin/sh
2 # FS QA Test No. 019
3 #
4 # mkfs protofile test
5 #
6 #-----------------------------------------------------------------------
7 #  Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
8 #  This program is free software; you can redistribute it and/or modify
9 #  it under the terms of the GNU General Public License as published by
10 #  the Free Software Foundation; either version 2 of the License, or
11 #  (at your option) any later version.
12 #
13 #  This program is distributed in the hope that it will be useful,
14 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 #  GNU General Public License for more details.
17 #
18 #  You should have received a copy of the GNU General Public License
19 #  along with this program; if not, write to the Free Software
20 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
21 #  USA
22 #
23 #  Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
24 #  Mountain View, CA 94043, USA, or: http://www.sgi.com
25 #-----------------------------------------------------------------------
26 #
27 # creator
28 owner=dxm@sgi.com
29
30 seq=`basename $0`
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35 seqfull="$seq.full"
36 status=1        # failure is the default!
37 # get standard environment, filters and checks
38 . ./common.rc
39 . ./common.filter
40
41 _cleanup()
42 {
43     echo "*** unmount"
44     umount $SCRATCH_MNT 2>/dev/null
45     rm -f $tmp.*
46 }
47 trap "_cleanup; exit \$status" 0 1 2 3 15
48
49 _full()
50 {
51     echo ""            >>$seqfull      
52     echo "*** $* ***"  >>$seqfull
53     echo ""            >>$seqfull
54 }
55
56 _filter_stat()
57 {
58     sed '
59         /^Access:/d;
60         /^Modify:/d;
61         /^Change:/d;
62         s/Device: *[0-9][0-9]*,[0-9][0-9]*/Device: <DEVICE>/;
63         s/Inode: *[0-9][0-9]*/Inode: <INODE>/;
64         s/Size: *[0-9][0-9]* *Filetype: Dir/Size: <DSIZE> Filetype: Dir/;
65     ' | tr -s ' '
66 }
67
68 # real QA test starts here
69 _supported_fs xfs
70 _supported_os IRIX Linux
71
72 _require_scratch
73
74 protofile=$tmp.proto
75 tempfile=$tmp.file
76
77 echo fish >$tempfile
78 $here/src/devzero -b 2048 -n 2 -c -v 44 $tempfile.2 
79
80 cat >$protofile <<EOF
81 DUMMY1
82 0 0
83 : root directory
84 d--777 3 1
85 : a directory
86 directory d--755 3 1 
87 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_0 ---755 3 1 $tempfile
88 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_1 ---755 3 1 $tempfile
89 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_2 ---755 3 1 $tempfile
90 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_3 ---755 3 1 $tempfile
91 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_4 ---755 3 1 $tempfile
92 $
93 : back in the root
94 setuid -u-666 0 0 $tempfile
95 setgid --g666 0 0 $tempfile
96 setugid -ug666 0 0 $tempfile
97 block_device b--012 3 1 161 162 
98 char_device c--345 3 1 177 178
99 pipe p--670 0 0
100 symlink l--123 0 0 bigfile
101 : a file we actually read
102 bigfile ---666 3 0 $tempfile.2
103 : done
104 $
105 EOF
106
107 if [ $? -ne 0 ]
108 then
109     _fail "failed to create test protofile"
110 fi
111
112 _verify_fs()
113 {
114         echo "*** create FS version $1"
115         VERSION="-n version=$1"
116
117         rm -f $seqfull
118         umount $SCRATCH_DEV >/dev/null 2>&1
119
120         _full "mkfs"
121         _scratch_mkfs_xfs $VERSION -p $protofile >>$seqfull 2>&1 \
122                 || _fail "mkfs failed"
123
124         echo "*** check FS"
125         _check_scratch_fs
126
127         echo "*** mount FS"
128         _full " mount"
129         _scratch_mount >>$seqfull 2>&1 \
130                 || _fail "mount failed"
131
132         echo "*** verify FS"
133         (cd $SCRATCH_MNT ; find . | sort \
134                 | xargs $here/src/lstat64 | _filter_stat)
135         diff -q $SCRATCH_MNT/bigfile $tempfile.2 \
136                 || _fail "bigfile corrupted"
137     
138         echo "*** unmount FS"
139         _full "umount"
140         umount $SCRATCH_DEV >>$seqfull 2>&1 \
141                 || _fail "umount failed"
142             
143         echo "*** check FS"
144         _check_scratch_fs
145 }
146
147 #_verify_fs 1
148 _verify_fs 2
149
150 echo "*** done"
151 rm $seqfull
152 status=0
153 exit