xref: /freebsd/contrib/netbsd-tests/fs/ffs/t_quotalimit.sh (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
1# $NetBSD: t_quotalimit.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $
2#
3#  Copyright (c) 2011 Manuel Bouyer
4#  All rights reserved.
5#
6#  Redistribution and use in source and binary forms, with or without
7#  modification, are permitted provided that the following conditions
8#  are met:
9#  1. Redistributions of source code must retain the above copyright
10#     notice, this list of conditions and the following disclaimer.
11#  2. Redistributions in binary form must reproduce the above copyright
12#     notice, this list of conditions and the following disclaimer in the
13#     documentation and/or other materials provided with the distribution.
14#
15#  THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16#  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17#  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19#  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25#  POSSIBILITY OF SUCH DAMAGE.
26#
27
28for e in le; do
29  for v in 1; do
30    for q in "user" "group"; do
31      test_case_root limit_${e}_${v}_${q} limit_quota \
32	 "hit hard limit quota with ${q} enabled" -b ${e} ${v} ${q}
33      test_case_root limit_${e}_${v}_${q}_log limit_quota \
34	 "hit hard limit quota with ${q} enabled, WAPBL" -bl ${e} ${v} ${q}
35      test_case_root slimit_${e}_${v}_${q} limit_softquota \
36	 "hit soft limit quota with ${q} enabled after grace time" \
37	 -b ${e} ${v} ${q}
38      test_case_root inolimit_${e}_${v}_${q} limit_iquota \
39	 "hit hard limit ino quota with ${q} enabled" -b ${e} ${v} ${q}
40      test_case_root inolimit_${e}_${v}_${q}_log limit_iquota \
41	 "hit hard limit ino quota with ${q} enabled, WAPBL" -bl ${e} ${v} ${q}
42      test_case_root sinolimit_${e}_${v}_${q} limit_softiquota \
43	 "hit soft limit ino quota with ${q} enabled after grace time" \
44	 -b ${e} ${v} ${q}
45      test_case_root herit_defq_${e}_${v}_${q} inherit_defaultquota \
46	 "new id herit from default for ${q} quota" -b ${e} ${v} ${q}
47      test_case_root herit_defq_${e}_${v}_${q}_log inherit_defaultquota \
48	 "new id herit from default for ${q} quota, WAPBL" -bl ${e} ${v} ${q}
49      test_case_root herit_idefq_${e}_${v}_${q}_log inherit_defaultiquota \
50	 "new id herit from default for ${q} ino quota, WAPBL" -bl ${e} ${v} ${q}
51    done
52  done
53done
54
55limit_quota()
56{
57	create_ffs_server $*
58	local q=$4
59	local expect
60	local id=1
61
62	case ${q} in
63	user)
64		expect=u
65		fail=g
66		;;
67	group)
68		expect=g
69		fail=u
70		;;
71	both)
72		expect="u g"
73		fail=""
74		;;
75	*)
76		atf_fail "wrong quota type"
77		;;
78	esac
79
80	for q in ${expect} ; do
81		atf_check -s exit:0 \
82		   env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2k/4 -h3k/6 \
83		   -t 2h/2h ${id}
84	done
85	atf_check -s exit:0 rump.halt
86
87	#now start the server which does the limits tests
88	atf_check -s exit:0 -o ignore \
89-e match:'test 0: write up to hard limit returned 69: Disc quota exceeded' \
90	    $(atf_get_srcdir)/h_quota2_tests -b 0 ${IMG} ${RUMP_SERVER}
91	for q in ${expect} ; do
92		atf_check -s exit:0 \
93		    -o match:'/mnt   3072 B\*  2048 B   3072 B     2:0      2       4       6         ' \
94		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id}
95		atf_check -s exit:0 \
96		    -o match:'daemon    \+-        3        2        3    2:0         2       4       6' \
97		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
98	done
99	rump_quota_shutdown
100}
101
102limit_softquota()
103{
104	create_ffs_server $*
105	local q=$4
106	local expect
107	local id=1
108
109	case ${q} in
110	user)
111		expect=u
112		fail=g
113		;;
114	group)
115		expect=g
116		fail=u
117		;;
118	both)
119		expect="u g"
120		fail=""
121		;;
122	*)
123		atf_fail "wrong quota type"
124		;;
125	esac
126
127	for q in ${expect} ; do
128		atf_check -s exit:0 \
129		   env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2k/4 -h3k/6 \
130		   -t 1s/1d ${id}
131	done
132	atf_check -s exit:0 rump.halt
133
134	#now start the server which does the limits tests
135	atf_check -s exit:0 -o ignore \
136-e match:'test 1: write beyond the soft limit after grace time returned 69: Disc quota exceeded' \
137	    $(atf_get_srcdir)/h_quota2_tests -b 1 ${IMG} ${RUMP_SERVER}
138	for q in ${expect} ; do
139		atf_check -s exit:0 \
140		    -o match:'/mnt   2560 B\*  2048 B   3072 B    none      2       4       6         ' \
141		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id}
142		atf_check -s exit:0 \
143		    -o match:'daemon    \+-        2        2        3   none         2       4       6' \
144		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
145	done
146	rump_quota_shutdown
147}
148
149limit_iquota()
150{
151	create_ffs_server $*
152	local q=$4
153	local expect
154	local id=1
155
156	case ${q} in
157	user)
158		expect=u
159		fail=g
160		;;
161	group)
162		expect=g
163		fail=u
164		;;
165	both)
166		expect="u g"
167		fail=""
168		;;
169	*)
170		atf_fail "wrong quota type"
171		;;
172	esac
173
174	for q in ${expect} ; do
175		atf_check -s exit:0 \
176		   env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2m/4 -h3m/6 \
177		   -t 2h/2h ${id}
178	done
179	atf_check -s exit:0 rump.halt
180
181	#now start the server which does the limits tests
182	atf_check -s exit:0 -o ignore \
183-e match:'test 2: create file up to hard limit returned 69: Disc quota exceeded' \
184	    $(atf_get_srcdir)/h_quota2_tests -b 2 ${IMG} ${RUMP_SERVER}
185	for q in ${expect} ; do
186		atf_check -s exit:0 \
187		    -o match:'/mnt   3072 B   2048 K   3072 K              6 \*     4       6      2:0' \
188		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id}
189		atf_check -s exit:0 \
190		    -o match:'daemon    -\+        3     2048     3072                6       4       6    2:0' \
191		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
192	done
193	rump_quota_shutdown
194}
195
196limit_softiquota()
197{
198	create_ffs_server $*
199	local q=$4
200	local expect
201	local id=1
202
203	case ${q} in
204	user)
205		expect=u
206		fail=g
207		;;
208	group)
209		expect=g
210		fail=u
211		;;
212	both)
213		expect="u g"
214		fail=""
215		;;
216	*)
217		atf_fail "wrong quota type"
218		;;
219	esac
220
221	for q in ${expect} ; do
222		atf_check -s exit:0 \
223		   env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2m/4 -h3m/6 \
224		   -t 1d/1s ${id}
225	done
226	atf_check -s exit:0 rump.halt
227
228	#now start the server which does the limits tests
229	atf_check -s exit:0 -o ignore \
230-e match:'test 3: create file beyond the soft limit after grace time returned 69: Disc quota exceeded' \
231	    $(atf_get_srcdir)/h_quota2_tests -b 3 ${IMG} ${RUMP_SERVER}
232	for q in ${expect} ; do
233		atf_check -s exit:0 \
234		    -o match:'/mnt   2560 B   2048 K   3072 K              5 \*     4       6     none' \
235		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id}
236		atf_check -s exit:0 \
237		    -o match:'daemon    -\+        2     2048     3072                5       4       6   none' \
238		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
239	done
240	rump_quota_shutdown
241}
242
243inherit_defaultquota()
244{
245	create_ffs_server $*
246	local q=$4
247	local expect
248	local id=1
249
250	case ${q} in
251	user)
252		expect=u
253		fail=g
254		;;
255	group)
256		expect=g
257		fail=u
258		;;
259	both)
260		expect="u g"
261		fail=""
262		;;
263	*)
264		atf_fail "wrong quota type"
265		;;
266	esac
267
268	for q in ${expect} ; do
269		atf_check -s exit:0 \
270		   env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2k/4 -h3k/6 \
271		   -t 2h/2h -d
272	done
273	for q in ${expect} ; do
274		atf_check -s exit:0 \
275		    -o match:'Disk quotas for .*id 1\): none' \
276		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -v ${id}
277	done
278	atf_check -s exit:0 rump.halt
279
280	#now start the server which does the limits tests
281	atf_check -s exit:0 -o ignore \
282-e match:'test 0: write up to hard limit returned 69: Disc quota exceeded' \
283	    $(atf_get_srcdir)/h_quota2_tests -b 0 ${IMG} ${RUMP_SERVER}
284	for q in ${expect} ; do
285		atf_check -s exit:0 \
286		    -o match:'/mnt   3072 B\*  2048 B   3072 B     2:0      2       4       6         ' \
287		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id}
288		atf_check -s exit:0 \
289		    -o match:'daemon    \+-        3        2        3    2:0         2       4       6' \
290		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
291	done
292	rump_quota_shutdown
293}
294
295inherit_defaultiquota()
296{
297	create_ffs_server $*
298	local q=$4
299	local expect
300	local id=1
301
302	case ${q} in
303	user)
304		expect=u
305		fail=g
306		;;
307	group)
308		expect=g
309		fail=u
310		;;
311	both)
312		expect="u g"
313		fail=""
314		;;
315	*)
316		atf_fail "wrong quota type"
317		;;
318	esac
319
320	for q in ${expect} ; do
321		atf_check -s exit:0 \
322		   env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2m/4 -h3m/6 \
323		   -t 2h/2h -d
324	done
325	for q in ${expect} ; do
326		atf_check -s exit:0 \
327		    -o match:'Disk quotas for .*id 1\): none' \
328		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -v ${id}
329	done
330	atf_check -s exit:0 rump.halt
331
332	#now start the server which does the limits tests
333	atf_check -s exit:0 -o ignore \
334-e match:'test 2: create file up to hard limit returned 69: Disc quota exceeded' \
335	    $(atf_get_srcdir)/h_quota2_tests -b 2 ${IMG} ${RUMP_SERVER}
336	for q in ${expect} ; do
337		atf_check -s exit:0 \
338		    -o match:'/mnt   3072 B   2048 K   3072 K              6 \*     4       6      2:0' \
339		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id}
340		atf_check -s exit:0 \
341		    -o match:'daemon    -\+        3     2048     3072                6       4       6    2:0' \
342		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
343	done
344	rump_quota_shutdown
345}
346