filter out parent output for mkfs
[xfstests-dev.git] / 106
1 #! /bin/sh
2 # FS QA Test No. 106
3 #
4 # Exercise basic xfs_quota functionality (user/group/project quota)
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
8 #-----------------------------------------------------------------------
9 #
10 # creator
11 owner=nathans@sgi.com
12
13 seq=`basename $0`
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
20
21 # get standard environment, filters and checks
22 . ./common.rc
23 . ./common.filter
24 . ./common.quota
25
26 _supported_fs xfs
27 _supported_os Linux #IRIX
28 _require_scratch
29 _require_quota
30 _require_prjquota
31
32 # real QA test starts here
33 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
34 cat $tmp.mkfs >$seq.full
35 . $tmp.mkfs
36
37 # setup a default run
38 [ -z "$MOUNT_OPTIONS" ] && export MOUNT_OPTIONS="-o uquota"
39
40 # initial populate
41 _qmount
42 target=$SCRATCH_MNT/target
43 ltp/fsstress -s 0xdeed -m8 -w -p4 -n1000 $FSSTRESS_AVOID -d $target
44 ltp/fsstress -s 0xdeed -m8 -z -p4 -n1000 -fchproj=500 -fchown=500 -d $target
45
46 # also use space, to be able to go over/under limits easily
47 uid=255
48 gid=254
49 prid=253
50 rm -f $SCRATCH_MNT/resv
51 $XFS_IO_PROG -fc "resvsp 0 200m" -c "chproj $prid" $SCRATCH_MNT/resv
52 chown $uid $SCRATCH_MNT/resv
53 chgrp $gid $SCRATCH_MNT/resv
54
55 _qmount
56
57 filter_xfs_quota()
58 {
59         perl -ne "
60 s,$SCRATCH_MNT,[SCR_MNT],;
61 s,$SCRATCH_DEV,[SCR_DEV],;
62 s/Inode: \#\d+ \(0 blocks, 0 extents\)/Inode: #[INO] (0 blocks, 0 extents)/;
63 s/Inode: \#\d+ \(\d+ blocks, \d+ extents\)/Inode: #[INO] (X blocks, Y extents)/;
64         print;"
65 }
66
67 test_quot()
68 {
69         echo "checking quot command (type=$type)"  # not deterministic on blks
70         xfs_quota -x -c "quot -n -$type" $SCRATCH_MNT >>$seq.full 2>&1
71 }
72
73 test_report()
74 {
75         echo "checking report command (type=$type)"
76         xfs_quota -x -c "report -h -$type -U 256" $SCRATCH_MNT
77 }
78
79 test_limit1()
80 {
81         echo "checking limit command, pass 1 (type=$type)"
82         xfs_quota -x -c "limit -$type bsoft=100m bhard=100m ihard=2 $id" \
83                 $SCRATCH_MNT
84         xfs_quota -x -c "limit -$type isoft=1 rtbsoft=100m rtbhard=110m $id"\
85                 $SCRATCH_MNT
86         sleep 2         # let the timer day transition happen
87         xfs_quota -x -c "quota -$type -b -hnv $id" $SCRATCH_MNT
88         xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
89         #xfs_quota -x -c "quota -$type -r -hnv $id" $SCRATCH_MNT
90 }
91
92 test_limit2()
93 {
94         # push limits up high, so that timers are cleared, etc. (for later)
95         echo "checking limit command, pass2 (type=$type)"
96         xfs_quota -x -c "limit -$type bsoft=300m bhard=400m ihard=8800 $id" \
97                 $SCRATCH_MNT
98         xfs_quota -x -c "limit -$type isoft=8000 rtbsoft=310m rtbhard=410m $id"\
99                 $SCRATCH_MNT
100         xfs_quota -x -c "quota -$type -b -hnv $id" $SCRATCH_MNT
101         xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
102         #xfs_quota -x -c "quota -$type -r -hnv $id" $SCRATCH_MNT
103 }
104
105 test_warn()
106 {
107         echo "checking warn command (type=$type)"
108         xfs_quota -x -c "warn -$type -b 4 $id" $SCRATCH_MNT
109         xfs_quota -x -c "warn -$type -i 3 $id" $SCRATCH_MNT
110         #xfs_quota -x -c "warn -$type -r 2 $id" $SCRATCH_MNT
111         xfs_quota -x -c "quota -$type -b -hnv $id" $SCRATCH_MNT
112         xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
113         #xfs_quota -x -c "quota -$type -r -hnv $id" $SCRATCH_MNT
114 }
115
116 test_timer()
117 {
118         echo "checking timer command (type=$type)"
119         xfs_quota -x -c "timer -$type -b 3days" $SCRATCH_MNT
120         xfs_quota -x -c "timer -$type -i 2days" $SCRATCH_MNT
121         #xfs_quota -x -c "timer -$type -r 1day" $SCRATCH_MNT
122 }
123
124 test_state()
125 {
126         echo "checking state command (type=$type)"
127         xfs_quota -x -c "state -$type" $SCRATCH_MNT
128         # not yet working properly?
129         #echo "checking disable command (type=$type)"
130         #xfs_quota -x -c "disable -$type -v" $SCRATCH_MNT
131         #echo "checking enable command (type=$type)"
132         #xfs_quota -x -c "enable -$type -v" $SCRATCH_MNT
133         #echo "checking off command (type=$type)"
134         #xfs_quota -x -c "off -$type -v" $SCRATCH_MNT
135         #echo "checking remove command (type=$type)"
136         #xfs_quota -x -c "remove -$type -v" $SCRATCH_MNT
137 }
138
139 test_backup()
140 {
141         echo "checking dump command (type=$type)"
142         rm -f $tmp.backup
143         xfs_quota -x -c "dump -$type -f $tmp.backup -U 256" $SCRATCH_MNT
144         cat $tmp.backup
145
146         echo "changing limits (type=$type)"
147         xfs_quota -x -c "limit -$type isoft=1000 ihard=1100 $id" $SCRATCH_MNT
148         xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
149
150         echo "checking restore command (type=$type)"
151         xfs_quota -x -c "restore -$type -f $tmp.backup" $SCRATCH_MNT
152         xfs_quota -x -c "quota -$type -i -hnv $id" $SCRATCH_MNT
153         rm -f $tmp.backup
154 }
155
156 test_xfs_quota()
157 {
158         test_quot       ; echo
159         test_report     ; echo
160         test_timer      ; echo
161         test_limit1     ; echo
162         test_warn       ; echo
163         test_limit2     ; echo
164         test_backup     ; echo
165         test_state      ; echo
166         echo            ; echo
167 }
168
169 # real QA test starts here
170 export MOUNT_OPTIONS="-ouquota"
171 _qmount
172 type=u
173 id=$uid
174 test_xfs_quota | filter_xfs_quota
175
176 export MOUNT_OPTIONS="-ogquota"
177 _qmount
178 type=g
179 id=$gid
180 test_xfs_quota | filter_xfs_quota
181
182 export MOUNT_OPTIONS="-opquota"
183 _qmount
184 type=p
185 id=$prid
186 test_xfs_quota | filter_xfs_quota
187
188 umount $SCRATCH_DEV
189 status=0
190 exit