t_setquota.sh revision 1.3 1 1.3 bouyer # $NetBSD: t_setquota.sh,v 1.3 2011/03/09 19:04:58 bouyer Exp $
2 1.2 bouyer #
3 1.2 bouyer # Copyright (c) 2011 Manuel Bouyer
4 1.2 bouyer # All rights reserved.
5 1.2 bouyer #
6 1.2 bouyer # Redistribution and use in source and binary forms, with or without
7 1.2 bouyer # modification, are permitted provided that the following conditions
8 1.2 bouyer # are met:
9 1.2 bouyer # 1. Redistributions of source code must retain the above copyright
10 1.2 bouyer # notice, this list of conditions and the following disclaimer.
11 1.2 bouyer # 2. Redistributions in binary form must reproduce the above copyright
12 1.2 bouyer # notice, this list of conditions and the following disclaimer in the
13 1.2 bouyer # documentation and/or other materials provided with the distribution.
14 1.2 bouyer #
15 1.2 bouyer # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.2 bouyer # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.2 bouyer # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.2 bouyer # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.2 bouyer # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.2 bouyer # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.2 bouyer # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.2 bouyer # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.2 bouyer # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.2 bouyer # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.2 bouyer # POSSIBILITY OF SUCH DAMAGE.
26 1.2 bouyer #
27 1.2 bouyer
28 1.2 bouyer for e in le be; do
29 1.2 bouyer for v in 1 2; do
30 1.2 bouyer for q in "user" "group"; do
31 1.2 bouyer test_case_root set_${e}_${v}_${q} set_quota \
32 1.2 bouyer "set quota with ${q} enabled" -b ${e} ${v} ${q}
33 1.2 bouyer test_case_root set_new_${e}_${v}_${q} set_quota_new \
34 1.2 bouyer "set quota for new id with ${q} enabled" -b ${e} ${v} ${q}
35 1.2 bouyer test_case_root set_default_${e}_${v}_${q} set_quota_default \
36 1.2 bouyer "set default quota with ${q} enabled" -b ${e} ${v} ${q}
37 1.2 bouyer done
38 1.2 bouyer test_case_root set_${e}_${v}_"both" set_quota \
39 1.2 bouyer "set quota with both enabled" -b ${e} ${v} "both"
40 1.2 bouyer test_case_root set_new_${e}_${v}_"both" set_quota_new \
41 1.2 bouyer "set quota for new id with both enabled" -b ${e} ${v} "both"
42 1.2 bouyer test_case_root set_new_${e}_${v}_"both_log" set_quota_new \
43 1.2 bouyer "set quota for new id with both enabled, WAPBL" -bl ${e} ${v} "both"
44 1.2 bouyer test_case_root set_default_${e}_${v}_"both" set_quota_default \
45 1.2 bouyer "set default quota with both enabled" -b ${e} ${v} "both"
46 1.2 bouyer done
47 1.2 bouyer done
48 1.2 bouyer
49 1.2 bouyer set_quota()
50 1.2 bouyer {
51 1.2 bouyer create_with_quotas_server $*
52 1.2 bouyer local q=$4
53 1.2 bouyer local expect
54 1.2 bouyer local fail
55 1.2 bouyer
56 1.2 bouyer case ${q} in
57 1.2 bouyer user)
58 1.2 bouyer expect=u
59 1.2 bouyer fail=g
60 1.2 bouyer ;;
61 1.2 bouyer group)
62 1.2 bouyer expect=g
63 1.2 bouyer fail=u
64 1.2 bouyer ;;
65 1.2 bouyer both)
66 1.2 bouyer expect="u g"
67 1.2 bouyer fail=""
68 1.2 bouyer ;;
69 1.2 bouyer *)
70 1.2 bouyer atf_fail "wrong quota type"
71 1.2 bouyer ;;
72 1.2 bouyer esac
73 1.2 bouyer
74 1.2 bouyer #check that we can set the expected quota
75 1.2 bouyer for q in ${expect} ; do
76 1.2 bouyer local id=$(id -${q})
77 1.2 bouyer atf_check -s exit:0 \
78 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \
79 1.2 bouyer -t 2W/3D ${id}
80 1.2 bouyer atf_check -s exit:0 \
81 1.2 bouyer -o "match:/mnt 0 10 40960 2weeks 1 20 51200 3days" \
82 1.2 bouyer -o "match:Disk quotas for .*: $" \
83 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v
84 1.2 bouyer atf_check -s exit:0 \
85 1.2 bouyer -o "match:-- 0 10 40960 1 20 51200" \
86 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt
87 1.2 bouyer done
88 1.2 bouyer
89 1.2 bouyer #check that we do not get positive reply for non-expected quota
90 1.2 bouyer for q in ${fail} ; do
91 1.2 bouyer local id=$(id -${q})
92 1.2 bouyer atf_check -s exit:0 \
93 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k ${id}
94 1.2 bouyer atf_check -s exit:0 -o "not-match:/mnt" \
95 1.2 bouyer -o "not-match:Disk quotas for .*: $" \
96 1.2 bouyer -o "match:Disk quotas for .*: none$" \
97 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v
98 1.2 bouyer atf_check -s exit:0 \
99 1.2 bouyer -o "not-match:-- 0 - -" \
100 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt
101 1.2 bouyer done
102 1.2 bouyer rump_shutdown
103 1.2 bouyer }
104 1.2 bouyer
105 1.2 bouyer set_quota_new()
106 1.2 bouyer {
107 1.2 bouyer create_with_quotas_server $*
108 1.2 bouyer local q=$4
109 1.2 bouyer local expect
110 1.2 bouyer local fail
111 1.2 bouyer
112 1.2 bouyer case ${q} in
113 1.2 bouyer user)
114 1.2 bouyer expect=u
115 1.2 bouyer fail=g
116 1.2 bouyer ;;
117 1.2 bouyer group)
118 1.2 bouyer expect=g
119 1.2 bouyer fail=u
120 1.2 bouyer ;;
121 1.2 bouyer both)
122 1.2 bouyer expect="u g"
123 1.2 bouyer fail=""
124 1.2 bouyer ;;
125 1.2 bouyer *)
126 1.2 bouyer atf_fail "wrong quota type"
127 1.2 bouyer ;;
128 1.2 bouyer esac
129 1.2 bouyer
130 1.2 bouyer #check that we can set the expected quota
131 1.2 bouyer for q in ${expect} ; do
132 1.2 bouyer local id=1
133 1.2 bouyer atf_check -s exit:0 \
134 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \
135 1.2 bouyer -t 120W/255D ${id}
136 1.2 bouyer atf_check -s exit:0 \
137 1.2 bouyer -o "match:/mnt 0 10 40960 2years 0 20 51200 9months" \
138 1.2 bouyer -o "match:Disk quotas for .*: $" \
139 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id}
140 1.2 bouyer done
141 1.2 bouyer
142 1.2 bouyer #check that we do not get positive reply for non-expected quota
143 1.2 bouyer for q in ${fail} ; do
144 1.2 bouyer local id=$(id -${q})
145 1.2 bouyer atf_check -s exit:0 \
146 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k ${id}
147 1.2 bouyer atf_check -s exit:0 -o "not-match:/mnt" \
148 1.2 bouyer -o "not-match:Disk quotas for .*: $" \
149 1.2 bouyer -o "match:Disk quotas for .*: none$" \
150 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id}
151 1.2 bouyer done
152 1.2 bouyer rump_shutdown
153 1.2 bouyer }
154 1.2 bouyer
155 1.2 bouyer set_quota_default()
156 1.2 bouyer {
157 1.2 bouyer create_with_quotas_server $*
158 1.2 bouyer local q=$4
159 1.2 bouyer local expect
160 1.2 bouyer local fail
161 1.2 bouyer
162 1.2 bouyer case ${q} in
163 1.2 bouyer user)
164 1.2 bouyer expect=u
165 1.2 bouyer fail=g
166 1.2 bouyer ;;
167 1.2 bouyer group)
168 1.2 bouyer expect=g
169 1.2 bouyer fail=u
170 1.2 bouyer ;;
171 1.2 bouyer both)
172 1.2 bouyer expect="u g"
173 1.2 bouyer fail=""
174 1.2 bouyer ;;
175 1.2 bouyer *)
176 1.2 bouyer atf_fail "wrong quota type"
177 1.2 bouyer ;;
178 1.2 bouyer esac
179 1.2 bouyer
180 1.2 bouyer #check that we can set the expected quota
181 1.2 bouyer for q in ${expect} ; do
182 1.2 bouyer local id="-d"
183 1.2 bouyer atf_check -s exit:0 \
184 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \
185 1.2 bouyer -t 2H2M/3540 ${id}
186 1.2 bouyer atf_check -s exit:0 \
187 1.2 bouyer -o "match:/mnt 0 10 40960 2:2 0 20 51200 59" \
188 1.2 bouyer -o "match:Default (user|group) disk quotas: $" \
189 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id}
190 1.2 bouyer done
191 1.2 bouyer
192 1.2 bouyer #check that we do not get positive reply for non-expected quota
193 1.2 bouyer for q in ${fail} ; do
194 1.2 bouyer local id="-d"
195 1.2 bouyer atf_check -s exit:0 \
196 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k ${id}
197 1.2 bouyer atf_check -s exit:0 -o "not-match:/mnt" \
198 1.2 bouyer -o "not-match:Default (user|group) disk quotas: $" \
199 1.2 bouyer -o "match:Default (user|group) disk quotas: none$" \
200 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id}
201 1.2 bouyer done
202 1.2 bouyer rump_shutdown
203 1.2 bouyer }
204