updates to match top of tree, grpquota support, fix output to match 3.01
[xfstests-dev.git] / 050
1 #! /bin/sh
2 # XFS QA Test No. 050
3 # $Id: 1.1 $
4 #
5 # Exercises basic XFS quota functionality
6 #       MOUNT_OPTIONS env var switches the test type (uid/gid/acct/enfd)
7 #       options are:  (-o) usrquota, grpquota, uqnoenforce, gqnoenforce
8 #       default is:   usrquota
9 #
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
12
13 # This program is free software; you can redistribute it and/or modify it
14 # under the terms of version 2 of the GNU General Public License as
15 # published by the Free Software Foundation.
16
17 # This program is distributed in the hope that it would be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20
21 # Further, this software is distributed without any warranty that it is
22 # free of the rightful claim of any third person regarding infringement
23 # or the like.  Any license provided herein, whether implied or
24 # otherwise, applies only to this software file.  Patent licenses, if
25 # any, provided herein do not apply to combinations of this program with
26 # other software, or any other product whatsoever.
27
28 # You should have received a copy of the GNU General Public License along
29 # with this program; if not, write the Free Software Foundation, Inc., 59
30 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
31
32 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
33 # Mountain View, CA  94043, or:
34
35 # http://www.sgi.com 
36
37 # For further information regarding this notice, see: 
38
39 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
40 #-----------------------------------------------------------------------
41 #
42 # creator
43 owner=nathans@sgi.com
44
45 seq=`basename $0`
46 echo "QA output created by $seq"
47
48 here=`pwd`
49 tmp=/tmp/$$
50 status=1        # failure is the default!
51
52 # get standard environment, filters and checks
53 . ./common.rc
54 . ./common.filter
55 . ./common.quota
56
57 _cleanup()
58 {
59         echo; echo "*** unmount"
60         umount $SCRATCH_MNT 2>/dev/null
61         rm -f $tmp.*
62 }
63 trap "_cleanup; exit \$status" 0 1 2 3 15
64 rm -f $seq.full $seq.out
65
66 _require_scratch
67 _require_quota
68
69 # setup a default run
70 if [ -z "$MOUNT_OPTIONS" ]; then
71         MOUNT_OPTIONS="-o usrquota"; export MOUNT_OPTIONS
72 fi
73
74 # real QA test starts here
75 mkfs -t xfs -f $SCRATCH_DEV | _filter_mkfs 2>$tmp.mkfs
76 cat $tmp.mkfs >>$seq.full
77 chmod a+w $seq.full     # arbitrary users will write here
78
79 # keep the blocksize and data size for dd later
80 . $tmp.mkfs
81
82 _qmount
83
84 # setup exactly what it is we'll be testing
85 if src/feature -u $SCRATCH_DEV
86 then
87         type=u ; id=`_choose_uid`; ln $seq.usrquota $seq.out
88 elif src/feature -g $SCRATCH_DEV
89 then
90         type=g ; id=`_choose_gid`; ln $seq.grpquota $seq.out
91 elif src/feature -U $SCRATCH_DEV
92 then
93         type=u ; id=`_choose_uid`; ln $seq.uqnoenforce $seq.out
94 elif src/feature -G $SCRATCH_DEV
95 then
96         type=g ; id=`_choose_gid`; ln $seq.gqnoenforce $seq.out
97 else
98         _notrun "No quota support at mount time"
99 fi
100
101 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
102 echo "and using type=$type id=$id" >>$seq.full
103
104 echo
105 echo "*** report no quota settings" | tee -a $seq.full
106 repquota -$type $SCRATCH_DEV | _filter_repquota
107
108 echo
109 echo "*** report initial settings" | tee -a $seq.full
110 setquota -$type $id 100 500 4 10 $SCRATCH_DEV
111 _file_as_id $SCRATCH_MNT/initme $id $type 1024 0
112 repquota -$type $SCRATCH_DEV | _filter_repquota
113
114 echo
115 echo "*** push past the soft inode limit" | tee -a $seq.full
116 _file_as_id $SCRATCH_MNT/softie1 $id $type 1024 0
117 _file_as_id $SCRATCH_MNT/softie2 $id $type 1024 0
118 _qmount
119 repquota -$type $SCRATCH_DEV | _filter_repquota
120
121 echo
122 echo "*** push past the soft block limit" | tee -a $seq.full
123 _file_as_id $SCRATCH_MNT/softie $id $type 1024 140
124 _qmount
125 repquota -$type $SCRATCH_DEV | _filter_repquota
126
127 echo
128 echo "*** push past the hard inode limit (expect EDQUOT)" | tee -a $seq.full
129 for i in 1 2 3 4 5 6 7 8 9 10 11 12
130 do
131         _file_as_id $SCRATCH_MNT/hard$i $id $type 1024 0
132 done
133 _qmount
134 repquota -$type $SCRATCH_DEV | _filter_repquota
135
136 echo
137 echo "*** push past the hard block limit (expect EDQUOT)" | tee -a $seq.full
138 _file_as_id $SCRATCH_MNT/softie $id $type 1024 540
139 _qmount
140 repquota -$type $SCRATCH_DEV | _filter_repquota
141
142 # success, all done
143 status=0
144 exit