1 1.4 bouyer # $NetBSD: t_quotalimit.sh,v 1.4 2012/01/18 20:51:23 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; do 29 1.2 bouyer for v in 1; do 30 1.2 bouyer for q in "user" "group"; do 31 1.2 bouyer test_case_root limit_${e}_${v}_${q} limit_quota \ 32 1.2 bouyer "hit hard limit quota with ${q} enabled" -b ${e} ${v} ${q} 33 1.2 bouyer test_case_root limit_${e}_${v}_${q}_log limit_quota \ 34 1.2 bouyer "hit hard limit quota with ${q} enabled, WAPBL" -bl ${e} ${v} ${q} 35 1.2 bouyer test_case_root slimit_${e}_${v}_${q} limit_softquota \ 36 1.2 bouyer "hit soft limit quota with ${q} enabled after grace time" \ 37 1.2 bouyer -b ${e} ${v} ${q} 38 1.2 bouyer test_case_root inolimit_${e}_${v}_${q} limit_iquota \ 39 1.2 bouyer "hit hard limit ino quota with ${q} enabled" -b ${e} ${v} ${q} 40 1.2 bouyer test_case_root inolimit_${e}_${v}_${q}_log limit_iquota \ 41 1.2 bouyer "hit hard limit ino quota with ${q} enabled, WAPBL" -bl ${e} ${v} ${q} 42 1.2 bouyer test_case_root sinolimit_${e}_${v}_${q} limit_softiquota \ 43 1.2 bouyer "hit soft limit ino quota with ${q} enabled after grace time" \ 44 1.2 bouyer -b ${e} ${v} ${q} 45 1.2 bouyer test_case_root herit_defq_${e}_${v}_${q} inherit_defaultquota \ 46 1.2 bouyer "new id herit from default for ${q} quota" -b ${e} ${v} ${q} 47 1.2 bouyer test_case_root herit_defq_${e}_${v}_${q}_log inherit_defaultquota \ 48 1.2 bouyer "new id herit from default for ${q} quota, WAPBL" -bl ${e} ${v} ${q} 49 1.2 bouyer test_case_root herit_idefq_${e}_${v}_${q}_log inherit_defaultiquota \ 50 1.2 bouyer "new id herit from default for ${q} ino quota, WAPBL" -bl ${e} ${v} ${q} 51 1.2 bouyer done 52 1.2 bouyer done 53 1.2 bouyer done 54 1.2 bouyer 55 1.2 bouyer limit_quota() 56 1.2 bouyer { 57 1.4 bouyer create_ffs_server $* 58 1.2 bouyer local q=$4 59 1.2 bouyer local expect 60 1.2 bouyer local id=1 61 1.2 bouyer 62 1.2 bouyer case ${q} in 63 1.2 bouyer user) 64 1.2 bouyer expect=u 65 1.2 bouyer fail=g 66 1.2 bouyer ;; 67 1.2 bouyer group) 68 1.2 bouyer expect=g 69 1.2 bouyer fail=u 70 1.2 bouyer ;; 71 1.2 bouyer both) 72 1.2 bouyer expect="u g" 73 1.2 bouyer fail="" 74 1.2 bouyer ;; 75 1.2 bouyer *) 76 1.2 bouyer atf_fail "wrong quota type" 77 1.2 bouyer ;; 78 1.2 bouyer esac 79 1.2 bouyer 80 1.2 bouyer for q in ${expect} ; do 81 1.2 bouyer atf_check -s exit:0 \ 82 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2k/4 -h3k/6 \ 83 1.2 bouyer -t 2h/2h ${id} 84 1.2 bouyer done 85 1.2 bouyer atf_check -s exit:0 rump.halt 86 1.2 bouyer 87 1.2 bouyer #now start the server which does the limits tests 88 1.2 bouyer atf_check -s exit:0 -o ignore \ 89 1.2 bouyer -e match:'test 0: write up to hard limit returned 69: Disc quota exceeded' \ 90 1.2 bouyer $(atf_get_srcdir)/h_quota2_tests -b 0 ${IMG} ${RUMP_SERVER} 91 1.2 bouyer for q in ${expect} ; do 92 1.2 bouyer atf_check -s exit:0 \ 93 1.2 bouyer -o match:'/mnt 3072 B\* 2048 B 3072 B 2:0 2 4 6 ' \ 94 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} 95 1.2 bouyer atf_check -s exit:0 \ 96 1.2 bouyer -o match:'daemon \+- 3 2 3 2:0 2 4 6' \ 97 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt 98 1.2 bouyer done 99 1.4 bouyer rump_quota_shutdown 100 1.2 bouyer } 101 1.2 bouyer 102 1.2 bouyer limit_softquota() 103 1.2 bouyer { 104 1.4 bouyer create_ffs_server $* 105 1.2 bouyer local q=$4 106 1.2 bouyer local expect 107 1.2 bouyer local id=1 108 1.2 bouyer 109 1.2 bouyer case ${q} in 110 1.2 bouyer user) 111 1.2 bouyer expect=u 112 1.2 bouyer fail=g 113 1.2 bouyer ;; 114 1.2 bouyer group) 115 1.2 bouyer expect=g 116 1.2 bouyer fail=u 117 1.2 bouyer ;; 118 1.2 bouyer both) 119 1.2 bouyer expect="u g" 120 1.2 bouyer fail="" 121 1.2 bouyer ;; 122 1.2 bouyer *) 123 1.2 bouyer atf_fail "wrong quota type" 124 1.2 bouyer ;; 125 1.2 bouyer esac 126 1.2 bouyer 127 1.2 bouyer for q in ${expect} ; do 128 1.2 bouyer atf_check -s exit:0 \ 129 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2k/4 -h3k/6 \ 130 1.2 bouyer -t 1s/1d ${id} 131 1.2 bouyer done 132 1.2 bouyer atf_check -s exit:0 rump.halt 133 1.2 bouyer 134 1.2 bouyer #now start the server which does the limits tests 135 1.2 bouyer atf_check -s exit:0 -o ignore \ 136 1.2 bouyer -e match:'test 1: write beyond the soft limit after grace time returned 69: Disc quota exceeded' \ 137 1.2 bouyer $(atf_get_srcdir)/h_quota2_tests -b 1 ${IMG} ${RUMP_SERVER} 138 1.2 bouyer for q in ${expect} ; do 139 1.2 bouyer atf_check -s exit:0 \ 140 1.2 bouyer -o match:'/mnt 2560 B\* 2048 B 3072 B none 2 4 6 ' \ 141 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} 142 1.2 bouyer atf_check -s exit:0 \ 143 1.2 bouyer -o match:'daemon \+- 2 2 3 none 2 4 6' \ 144 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt 145 1.2 bouyer done 146 1.4 bouyer rump_quota_shutdown 147 1.2 bouyer } 148 1.2 bouyer 149 1.2 bouyer limit_iquota() 150 1.2 bouyer { 151 1.4 bouyer create_ffs_server $* 152 1.2 bouyer local q=$4 153 1.2 bouyer local expect 154 1.2 bouyer local id=1 155 1.2 bouyer 156 1.2 bouyer case ${q} in 157 1.2 bouyer user) 158 1.2 bouyer expect=u 159 1.2 bouyer fail=g 160 1.2 bouyer ;; 161 1.2 bouyer group) 162 1.2 bouyer expect=g 163 1.2 bouyer fail=u 164 1.2 bouyer ;; 165 1.2 bouyer both) 166 1.2 bouyer expect="u g" 167 1.2 bouyer fail="" 168 1.2 bouyer ;; 169 1.2 bouyer *) 170 1.2 bouyer atf_fail "wrong quota type" 171 1.2 bouyer ;; 172 1.2 bouyer esac 173 1.2 bouyer 174 1.2 bouyer for q in ${expect} ; do 175 1.2 bouyer atf_check -s exit:0 \ 176 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2m/4 -h3m/6 \ 177 1.2 bouyer -t 2h/2h ${id} 178 1.2 bouyer done 179 1.2 bouyer atf_check -s exit:0 rump.halt 180 1.2 bouyer 181 1.2 bouyer #now start the server which does the limits tests 182 1.2 bouyer atf_check -s exit:0 -o ignore \ 183 1.2 bouyer -e match:'test 2: create file up to hard limit returned 69: Disc quota exceeded' \ 184 1.2 bouyer $(atf_get_srcdir)/h_quota2_tests -b 2 ${IMG} ${RUMP_SERVER} 185 1.2 bouyer for q in ${expect} ; do 186 1.2 bouyer atf_check -s exit:0 \ 187 1.2 bouyer -o match:'/mnt 3072 B 2048 K 3072 K 6 \* 4 6 2:0' \ 188 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} 189 1.2 bouyer atf_check -s exit:0 \ 190 1.2 bouyer -o match:'daemon -\+ 3 2048 3072 6 4 6 2:0' \ 191 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt 192 1.2 bouyer done 193 1.4 bouyer rump_quota_shutdown 194 1.2 bouyer } 195 1.2 bouyer 196 1.2 bouyer limit_softiquota() 197 1.2 bouyer { 198 1.4 bouyer create_ffs_server $* 199 1.2 bouyer local q=$4 200 1.2 bouyer local expect 201 1.2 bouyer local id=1 202 1.2 bouyer 203 1.2 bouyer case ${q} in 204 1.2 bouyer user) 205 1.2 bouyer expect=u 206 1.2 bouyer fail=g 207 1.2 bouyer ;; 208 1.2 bouyer group) 209 1.2 bouyer expect=g 210 1.2 bouyer fail=u 211 1.2 bouyer ;; 212 1.2 bouyer both) 213 1.2 bouyer expect="u g" 214 1.2 bouyer fail="" 215 1.2 bouyer ;; 216 1.2 bouyer *) 217 1.2 bouyer atf_fail "wrong quota type" 218 1.2 bouyer ;; 219 1.2 bouyer esac 220 1.2 bouyer 221 1.2 bouyer for q in ${expect} ; do 222 1.2 bouyer atf_check -s exit:0 \ 223 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2m/4 -h3m/6 \ 224 1.2 bouyer -t 1d/1s ${id} 225 1.2 bouyer done 226 1.2 bouyer atf_check -s exit:0 rump.halt 227 1.2 bouyer 228 1.2 bouyer #now start the server which does the limits tests 229 1.2 bouyer atf_check -s exit:0 -o ignore \ 230 1.2 bouyer -e match:'test 3: create file beyond the soft limit after grace time returned 69: Disc quota exceeded' \ 231 1.2 bouyer $(atf_get_srcdir)/h_quota2_tests -b 3 ${IMG} ${RUMP_SERVER} 232 1.2 bouyer for q in ${expect} ; do 233 1.2 bouyer atf_check -s exit:0 \ 234 1.2 bouyer -o match:'/mnt 2560 B 2048 K 3072 K 5 \* 4 6 none' \ 235 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} 236 1.2 bouyer atf_check -s exit:0 \ 237 1.2 bouyer -o match:'daemon -\+ 2 2048 3072 5 4 6 none' \ 238 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt 239 1.2 bouyer done 240 1.4 bouyer rump_quota_shutdown 241 1.2 bouyer } 242 1.2 bouyer 243 1.2 bouyer inherit_defaultquota() 244 1.2 bouyer { 245 1.4 bouyer create_ffs_server $* 246 1.2 bouyer local q=$4 247 1.2 bouyer local expect 248 1.2 bouyer local id=1 249 1.2 bouyer 250 1.2 bouyer case ${q} in 251 1.2 bouyer user) 252 1.2 bouyer expect=u 253 1.2 bouyer fail=g 254 1.2 bouyer ;; 255 1.2 bouyer group) 256 1.2 bouyer expect=g 257 1.2 bouyer fail=u 258 1.2 bouyer ;; 259 1.2 bouyer both) 260 1.2 bouyer expect="u g" 261 1.2 bouyer fail="" 262 1.2 bouyer ;; 263 1.2 bouyer *) 264 1.2 bouyer atf_fail "wrong quota type" 265 1.2 bouyer ;; 266 1.2 bouyer esac 267 1.2 bouyer 268 1.2 bouyer for q in ${expect} ; do 269 1.2 bouyer atf_check -s exit:0 \ 270 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2k/4 -h3k/6 \ 271 1.2 bouyer -t 2h/2h -d 272 1.2 bouyer done 273 1.2 bouyer for q in ${expect} ; do 274 1.2 bouyer atf_check -s exit:0 \ 275 1.2 bouyer -o match:'Disk quotas for .*id 1\): none' \ 276 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -v ${id} 277 1.2 bouyer done 278 1.2 bouyer atf_check -s exit:0 rump.halt 279 1.2 bouyer 280 1.2 bouyer #now start the server which does the limits tests 281 1.2 bouyer atf_check -s exit:0 -o ignore \ 282 1.2 bouyer -e match:'test 0: write up to hard limit returned 69: Disc quota exceeded' \ 283 1.2 bouyer $(atf_get_srcdir)/h_quota2_tests -b 0 ${IMG} ${RUMP_SERVER} 284 1.2 bouyer for q in ${expect} ; do 285 1.2 bouyer atf_check -s exit:0 \ 286 1.2 bouyer -o match:'/mnt 3072 B\* 2048 B 3072 B 2:0 2 4 6 ' \ 287 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} 288 1.2 bouyer atf_check -s exit:0 \ 289 1.2 bouyer -o match:'daemon \+- 3 2 3 2:0 2 4 6' \ 290 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt 291 1.2 bouyer done 292 1.4 bouyer rump_quota_shutdown 293 1.2 bouyer } 294 1.2 bouyer 295 1.2 bouyer inherit_defaultiquota() 296 1.2 bouyer { 297 1.4 bouyer create_ffs_server $* 298 1.2 bouyer local q=$4 299 1.2 bouyer local expect 300 1.2 bouyer local id=1 301 1.2 bouyer 302 1.2 bouyer case ${q} in 303 1.2 bouyer user) 304 1.2 bouyer expect=u 305 1.2 bouyer fail=g 306 1.2 bouyer ;; 307 1.2 bouyer group) 308 1.2 bouyer expect=g 309 1.2 bouyer fail=u 310 1.2 bouyer ;; 311 1.2 bouyer both) 312 1.2 bouyer expect="u g" 313 1.2 bouyer fail="" 314 1.2 bouyer ;; 315 1.2 bouyer *) 316 1.2 bouyer atf_fail "wrong quota type" 317 1.2 bouyer ;; 318 1.2 bouyer esac 319 1.2 bouyer 320 1.2 bouyer for q in ${expect} ; do 321 1.2 bouyer atf_check -s exit:0 \ 322 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s2m/4 -h3m/6 \ 323 1.2 bouyer -t 2h/2h -d 324 1.2 bouyer done 325 1.2 bouyer for q in ${expect} ; do 326 1.2 bouyer atf_check -s exit:0 \ 327 1.2 bouyer -o match:'Disk quotas for .*id 1\): none' \ 328 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -v ${id} 329 1.2 bouyer done 330 1.2 bouyer atf_check -s exit:0 rump.halt 331 1.2 bouyer 332 1.2 bouyer #now start the server which does the limits tests 333 1.2 bouyer atf_check -s exit:0 -o ignore \ 334 1.2 bouyer -e match:'test 2: create file up to hard limit returned 69: Disc quota exceeded' \ 335 1.2 bouyer $(atf_get_srcdir)/h_quota2_tests -b 2 ${IMG} ${RUMP_SERVER} 336 1.2 bouyer for q in ${expect} ; do 337 1.2 bouyer atf_check -s exit:0 \ 338 1.2 bouyer -o match:'/mnt 3072 B 2048 K 3072 K 6 \* 4 6 2:0' \ 339 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -$q -h ${id} 340 1.2 bouyer atf_check -s exit:0 \ 341 1.2 bouyer -o match:'daemon -\+ 3 2048 3072 6 4 6 2:0' \ 342 1.3 bouyer env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt 343 1.2 bouyer done 344 1.4 bouyer rump_quota_shutdown 345 1.2 bouyer } 346