t_setquota.sh revision 1.1.2.3 1 1.1.2.3 bouyer # $NetBSD: t_setquota.sh,v 1.1.2.3 2011/01/30 19:49:48 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.1 bouyer create_with_quotas $*
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.1 bouyer $(atf_get_srcdir)/rump_edquota -$q -s10k/20 -h40M/50k ${id}
77 1.1.2.1 bouyer atf_check -s exit:0 \
78 1.1.2.3 bouyer -o "match:/mnt 0 10 40960 7days 1 20 51200 7days" \
79 1.1.2.1 bouyer -o "match:Disk quotas for .*: $" \
80 1.1.2.1 bouyer $(atf_get_srcdir)/rump_quota -${q} -v
81 1.1.2.1 bouyer atf_check -s exit:0 \
82 1.1.2.1 bouyer -o "match:-- 0 10 40960 1 20 51200" \
83 1.1.2.1 bouyer $(atf_get_srcdir)/rump_repquota -${q} /mnt
84 1.1.2.1 bouyer done
85 1.1.2.1 bouyer
86 1.1.2.1 bouyer #check that we do not get positive reply for non-expected quota
87 1.1.2.1 bouyer for q in ${fail} ; do
88 1.1.2.1 bouyer local id=$(id -${q})
89 1.1.2.1 bouyer atf_check -s exit:0 \
90 1.1.2.1 bouyer $(atf_get_srcdir)/rump_edquota -$q -s10k/20 -h40M/50k ${id}
91 1.1.2.1 bouyer atf_check -s exit:0 -o "not-match:/mnt" \
92 1.1.2.1 bouyer -o "not-match:Disk quotas for .*: $" \
93 1.1.2.1 bouyer -o "match:Disk quotas for .*: none$" \
94 1.1.2.1 bouyer $(atf_get_srcdir)/rump_quota -${q} -v
95 1.1.2.1 bouyer atf_check -s exit:0 \
96 1.1.2.3 bouyer -o "not-match:-- 0 - -" \
97 1.1.2.1 bouyer $(atf_get_srcdir)/rump_repquota -${q} /mnt
98 1.1.2.1 bouyer done
99 1.1.2.1 bouyer atf_check -s exit:0 rump.halt
100 1.1.2.1 bouyer # check that the quota inode creation didn't corrupt the filesystem
101 1.1.2.1 bouyer atf_check -s exit:0 -o "match:already clean" \
102 1.1.2.1 bouyer -o "match:Phase 6 - Check Quotas" \
103 1.1.2.1 bouyer fsck_ffs -nf -F ${IMG}
104 1.1.2.1 bouyer }
105 1.1.2.1 bouyer
106 1.1.2.1 bouyer set_quota_new()
107 1.1.2.1 bouyer {
108 1.1.2.1 bouyer create_with_quotas $*
109 1.1.2.1 bouyer local q=$3
110 1.1.2.1 bouyer local expect
111 1.1.2.1 bouyer local fail
112 1.1.2.1 bouyer
113 1.1.2.1 bouyer case ${q} in
114 1.1.2.1 bouyer user)
115 1.1.2.1 bouyer expect=u
116 1.1.2.1 bouyer fail=g
117 1.1.2.1 bouyer ;;
118 1.1.2.1 bouyer group)
119 1.1.2.1 bouyer expect=g
120 1.1.2.1 bouyer fail=u
121 1.1.2.1 bouyer ;;
122 1.1.2.1 bouyer both)
123 1.1.2.1 bouyer expect="u g"
124 1.1.2.1 bouyer fail=""
125 1.1.2.1 bouyer ;;
126 1.1.2.1 bouyer *)
127 1.1.2.1 bouyer atf_fail "wrong quota type"
128 1.1.2.1 bouyer ;;
129 1.1.2.1 bouyer esac
130 1.1.2.1 bouyer
131 1.1.2.1 bouyer #check that we can set the expected quota
132 1.1.2.1 bouyer for q in ${expect} ; do
133 1.1.2.1 bouyer local id=1
134 1.1.2.1 bouyer atf_check -s exit:0 \
135 1.1.2.1 bouyer $(atf_get_srcdir)/rump_edquota -$q -s10k/20 -h40M/50k ${id}
136 1.1.2.1 bouyer atf_check -s exit:0 \
137 1.1.2.3 bouyer -o "match:/mnt 0 10 40960 7days 0 20 51200 7days" \
138 1.1.2.1 bouyer -o "match:Disk quotas for .*: $" \
139 1.1.2.1 bouyer $(atf_get_srcdir)/rump_quota -${q} -v ${id}
140 1.1.2.1 bouyer done
141 1.1.2.1 bouyer
142 1.1.2.1 bouyer #check that we do not get positive reply for non-expected quota
143 1.1.2.1 bouyer for q in ${fail} ; do
144 1.1.2.1 bouyer local id=$(id -${q})
145 1.1.2.1 bouyer atf_check -s exit:0 \
146 1.1.2.1 bouyer $(atf_get_srcdir)/rump_edquota -$q -s10k/20 -h40M/50k ${id}
147 1.1.2.1 bouyer atf_check -s exit:0 -o "not-match:/mnt" \
148 1.1.2.1 bouyer -o "not-match:Disk quotas for .*: $" \
149 1.1.2.1 bouyer -o "match:Disk quotas for .*: none$" \
150 1.1.2.1 bouyer $(atf_get_srcdir)/rump_quota -${q} -v ${id}
151 1.1.2.1 bouyer done
152 1.1.2.1 bouyer atf_check -s exit:0 rump.halt
153 1.1.2.1 bouyer # check that the quota inode creation didn't corrupt the filesystem
154 1.1.2.1 bouyer atf_check -s exit:0 -o "match:already clean" \
155 1.1.2.1 bouyer -o "match:Phase 6 - Check Quotas" \
156 1.1.2.1 bouyer fsck_ffs -nf -F ${IMG}
157 1.1.2.1 bouyer }
158 1.1.2.1 bouyer
159 1.1.2.1 bouyer set_quota_default()
160 1.1.2.1 bouyer {
161 1.1.2.1 bouyer create_with_quotas $*
162 1.1.2.1 bouyer local q=$3
163 1.1.2.1 bouyer local expect
164 1.1.2.1 bouyer local fail
165 1.1.2.1 bouyer
166 1.1.2.1 bouyer case ${q} in
167 1.1.2.1 bouyer user)
168 1.1.2.1 bouyer expect=u
169 1.1.2.1 bouyer fail=g
170 1.1.2.1 bouyer ;;
171 1.1.2.1 bouyer group)
172 1.1.2.1 bouyer expect=g
173 1.1.2.1 bouyer fail=u
174 1.1.2.1 bouyer ;;
175 1.1.2.1 bouyer both)
176 1.1.2.1 bouyer expect="u g"
177 1.1.2.1 bouyer fail=""
178 1.1.2.1 bouyer ;;
179 1.1.2.1 bouyer *)
180 1.1.2.1 bouyer atf_fail "wrong quota type"
181 1.1.2.1 bouyer ;;
182 1.1.2.1 bouyer esac
183 1.1.2.1 bouyer
184 1.1.2.1 bouyer #check that we can set the expected quota
185 1.1.2.1 bouyer for q in ${expect} ; do
186 1.1.2.1 bouyer local id="-d"
187 1.1.2.1 bouyer atf_check -s exit:0 \
188 1.1.2.1 bouyer $(atf_get_srcdir)/rump_edquota -$q -s10k/20 -h40M/50k ${id}
189 1.1.2.1 bouyer atf_check -s exit:0 \
190 1.1.2.3 bouyer -o "match:/mnt 0 10 40960 7days 0 20 51200 7days" \
191 1.1.2.1 bouyer -o "match:Default (user|group) disk quotas: $" \
192 1.1.2.1 bouyer $(atf_get_srcdir)/rump_quota -${q} -v ${id}
193 1.1.2.1 bouyer done
194 1.1.2.1 bouyer
195 1.1.2.1 bouyer #check that we do not get positive reply for non-expected quota
196 1.1.2.1 bouyer for q in ${fail} ; do
197 1.1.2.1 bouyer local id="-d"
198 1.1.2.1 bouyer atf_check -s exit:0 \
199 1.1.2.1 bouyer $(atf_get_srcdir)/rump_edquota -$q -s10k/20 -h40M/50k ${id}
200 1.1.2.1 bouyer atf_check -s exit:0 -o "not-match:/mnt" \
201 1.1.2.1 bouyer -o "not-match:Default (user|group) disk quotas: $" \
202 1.1.2.1 bouyer -o "match:Default (user|group) disk quotas: none$" \
203 1.1.2.1 bouyer $(atf_get_srcdir)/rump_quota -${q} -v ${id}
204 1.1.2.1 bouyer done
205 1.1.2.1 bouyer atf_check -s exit:0 rump.halt
206 1.1.2.1 bouyer # check that the quota inode creation didn't corrupt the filesystem
207 1.1.2.1 bouyer atf_check -s exit:0 -o "match:already clean" \
208 1.1.2.1 bouyer -o "match:Phase 6 - Check Quotas" \
209 1.1.2.1 bouyer fsck_ffs -nf -F ${IMG}
210 1.1.2.1 bouyer }
211