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