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