xfstests: eliminate warnings under dmapi/src/suite1/cmd (3)
[xfstests-dev.git] / 106
1 #! /bin/bash
2 # FS QA Test No. 106
3 #
4 # Exercise basic xfs_quota functionality (user/group/project quota)
5 # Use of "sync" mount option here is an attempt to get deterministic
6 # allocator behaviour.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #
24 #-----------------------------------------------------------------------
25 #
26 # creator
27 owner=nathans@sgi.com
28
29 seq=`basename $0`
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
36
37 # get standard environment, filters and checks
38 . ./common.rc
39 . ./common.filter
40 . ./common.quota
41
42 _supported_fs xfs
43 _supported_os Linux #IRIX
44 _require_scratch
45 _require_xfs_quota
46
47 # real QA test starts here
48 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
49 cat $tmp.mkfs >$seq.full
50 . $tmp.mkfs
51
52 # setup a default run
53 if [ -z "$MOUNT_OPTIONS" ]; then
54         export MOUNT_OPTIONS="-o pquota,sync"
55 else
56         export MOUNT_OPTIONS="$MOUNT_OPTIONS -o sync"
57 fi
58
59 _qmount
60 _require_prjquota $SCRATCH_DEV
61
62 # initial populate
63 target=$SCRATCH_MNT/target
64 $FSSTRESS_PROG -s 0xdeed -m8 -w -p4 -n1000 $FSSTRESS_AVOID -d $target
65 $FSSTRESS_PROG -s 0xdeed -m8 -z -p4 -n1000 -fsetxattr=500 -fchown=500 -d $target
66
67 # also use space, to be able to go over/under limits easily
68 uid=255
69 gid=254
70 prid=253
71 rm -f $SCRATCH_MNT/resv
72 $XFS_IO_PROG -fc "resvsp 0 200m" -c "chproj $prid" $SCRATCH_MNT/resv
73 chown $uid $SCRATCH_MNT/resv
74 chgrp $gid $SCRATCH_MNT/resv
75
76 _qmount
77
78 filter_xfs_quota()
79 {
80         perl -ne "
81 s,$SCRATCH_MNT,[SCR_MNT],;
82 s,$SCRATCH_DEV,[SCR_DEV],;
83 s/Inode: \#\d+ \(0 blocks, 0 extents\)/Inode: #[INO] (0 blocks, 0 extents)/;
84 s/Inode: \#\d+ \(\d+ blocks, \d+ extents\)/Inode: #[INO] (X blocks, Y extents)/;
85         print;"
86 }
87
88 test_quot()
89 {
90         echo "checking quot command (type=$type)"  # not deterministic on blks
91         xfs_quota -x -c "quot -n -$type" $SCRATCH_MNT >>$seq.full 2>&1
92 }
93
94 test_report()
95 {
96         echo "checking report command (type=$type)"
97         xfs_quota -x -c "report -h -$type -U 256" $SCRATCH_MNT
98 }
99
100 test_limit1()
101 {
102         echo "checking limit command, pass 1 (type=$type)"
103         xfs_quota -x -c "limit -$type bsoft=100m bhard=100m ihard=2 $id" \
104                 $SCRATCH_MNT
105         xfs_quota -x -c "limit -$type isoft=1 rtbsoft=100m rtbhard=110m $id"\
106                 $SCRATCH_MNT
107         sleep 2         # let the timer day transition happen
108         xfs_quota -x -c "quota -$type -b -hnv $id" $SCRATCH_MNT
109         xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
110         #xfs_quota -x -c "quota -$type -r -hnv $id" $SCRATCH_MNT
111 }
112
113 test_limit2()
114 {
115         # push limits up high, so that timers are cleared, etc. (for later)
116         echo "checking limit command, pass2 (type=$type)"
117         xfs_quota -x -c "limit -$type bsoft=300m bhard=400m ihard=8800 $id" \
118                 $SCRATCH_MNT
119         xfs_quota -x -c "limit -$type isoft=8000 rtbsoft=310m rtbhard=410m $id"\
120                 $SCRATCH_MNT
121         xfs_quota -x -c "quota -$type -b -hnv $id" $SCRATCH_MNT
122         xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
123         #xfs_quota -x -c "quota -$type -r -hnv $id" $SCRATCH_MNT
124 }
125
126 test_warn()
127 {
128         echo "checking warn command (type=$type)"
129         xfs_quota -x -c "warn -$type -b 4 $id" $SCRATCH_MNT
130         xfs_quota -x -c "warn -$type -i 3 $id" $SCRATCH_MNT
131         #xfs_quota -x -c "warn -$type -r 2 $id" $SCRATCH_MNT
132         xfs_quota -x -c "quota -$type -b -hnv $id" $SCRATCH_MNT
133         xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
134         #xfs_quota -x -c "quota -$type -r -hnv $id" $SCRATCH_MNT
135 }
136
137 test_timer()
138 {
139         echo "checking timer command (type=$type)"
140         xfs_quota -x -c "timer -$type -b 3days" $SCRATCH_MNT
141         xfs_quota -x -c "timer -$type -i 2days" $SCRATCH_MNT
142         #xfs_quota -x -c "timer -$type -r 1day" $SCRATCH_MNT
143 }
144
145 test_state()
146 {
147         echo "checking state command (type=$type)"
148         xfs_quota -x -c "state -$type" $SCRATCH_MNT
149         # not yet working properly?
150         #echo "checking disable command (type=$type)"
151         #xfs_quota -x -c "disable -$type -v" $SCRATCH_MNT
152         #echo "checking enable command (type=$type)"
153         #xfs_quota -x -c "enable -$type -v" $SCRATCH_MNT
154         #echo "checking off command (type=$type)"
155         #xfs_quota -x -c "off -$type -v" $SCRATCH_MNT
156         #echo "checking remove command (type=$type)"
157         #xfs_quota -x -c "remove -$type -v" $SCRATCH_MNT
158 }
159
160 test_backup()
161 {
162         echo "checking dump command (type=$type)"
163         rm -f $tmp.backup
164         xfs_quota -x -c "dump -$type -f $tmp.backup -U 256" $SCRATCH_MNT
165         cat $tmp.backup
166
167         echo "changing limits (type=$type)"
168         xfs_quota -x -c "limit -$type isoft=1000 ihard=1100 $id" $SCRATCH_MNT
169         xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
170
171         echo "checking restore command (type=$type)"
172         xfs_quota -x -c "restore -$type -f $tmp.backup" $SCRATCH_MNT
173         xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
174         rm -f $tmp.backup
175 }
176
177 test_xfs_quota()
178 {
179         test_quot       ; echo
180         test_report     ; echo
181         test_timer      ; echo
182         test_limit1     ; echo
183         test_warn       ; echo
184         test_limit2     ; echo
185         test_backup     ; echo
186         test_state      ; echo
187         echo            ; echo
188 }
189
190 # real QA test starts here
191 export MOUNT_OPTIONS="-ouquota,sync"
192 _qmount
193 type=u
194 id=$uid
195 test_xfs_quota | filter_xfs_quota
196
197 export MOUNT_OPTIONS="-ogquota,sync"
198 _qmount
199 type=g
200 id=$gid
201 test_xfs_quota | filter_xfs_quota
202
203 export MOUNT_OPTIONS="-opquota,sync"
204 _qmount
205 type=p
206 id=$prid
207 test_xfs_quota | filter_xfs_quota
208
209 umount $SCRATCH_DEV
210 status=0
211 exit