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