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