1272343Sngie# $NetBSD: t_clearquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ 2272343Sngie# 3272343Sngie# Copyright (c) 2011 Manuel Bouyer 4272343Sngie# All rights reserved. 5272343Sngie# 6272343Sngie# Redistribution and use in source and binary forms, with or without 7272343Sngie# modification, are permitted provided that the following conditions 8272343Sngie# are met: 9272343Sngie# 1. Redistributions of source code must retain the above copyright 10272343Sngie# notice, this list of conditions and the following disclaimer. 11272343Sngie# 2. Redistributions in binary form must reproduce the above copyright 12272343Sngie# notice, this list of conditions and the following disclaimer in the 13272343Sngie# documentation and/or other materials provided with the distribution. 14272343Sngie# 15272343Sngie# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16272343Sngie# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17272343Sngie# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18272343Sngie# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19272343Sngie# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20272343Sngie# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21272343Sngie# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22272343Sngie# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23272343Sngie# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24272343Sngie# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25272343Sngie# POSSIBILITY OF SUCH DAMAGE. 26272343Sngie# 27272343Sngie 28272343Sngiefor e in le be; do 29272343Sngie for v in 1 2; do 30272343Sngie for q in "user" "group"; do 31272343Sngie test_case_root clear_${e}_${v}_${q} clear_quota \ 32272343Sngie "clear quota with ${q} enabled" -b ${e} ${v} ${q} 33272343Sngie done 34272343Sngie test_case_root clear_${e}_${v}_"both" clear_quota \ 35272343Sngie "clear quota with both enabled" -b ${e} ${v} "both" 36272343Sngie test_case_root clear_${e}_${v}_"both_log" clear_quota \ 37272343Sngie "clear quota for new id with both enabled, WAPBL" -bl ${e} ${v} "both" 38272343Sngie done 39272343Sngiedone 40272343Sngie 41272343Sngieclear_quota() 42272343Sngie{ 43272343Sngie create_ffs_server $* 44272343Sngie local q=$4 45272343Sngie local expect 46272343Sngie local fail 47272343Sngie local id=1 48272343Sngie 49272343Sngie case ${q} in 50272343Sngie user) 51272343Sngie expect=u 52272343Sngie fail=g 53272343Sngie ;; 54272343Sngie group) 55272343Sngie expect=g 56272343Sngie fail=u 57272343Sngie ;; 58272343Sngie both) 59272343Sngie expect="u g" 60272343Sngie fail="" 61272343Sngie ;; 62272343Sngie *) 63272343Sngie atf_fail "wrong quota type" 64272343Sngie ;; 65272343Sngie esac 66272343Sngie 67272343Sngie#set and check the expected quota 68272343Sngie for q in ${expect} ; do 69272343Sngie atf_check -s exit:0 \ 70272343Sngie env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \ 71272343Sngie -t 2W/3D ${id} 72272343Sngie atf_check -s exit:0 \ 73272343Sngie-o "match:/mnt 0 10 40960 2weeks 0 20 51200 3days" \ 74272343Sngie-o "match:Disk quotas for .*: $" \ 75272343Sngie env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} 76272343Sngie done 77272343Sngie#now clear the quotas 78272343Sngie for q in ${expect} ; do 79272343Sngie atf_check -s exit:0 \ 80272343Sngie env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -c ${id} 81272343Sngie done; 82272343Sngie 83272343Sngie#check that we do not get positive reply for any quota type 84272343Sngie for q in u g ; do 85272343Sngie atf_check -s exit:0 -o "not-match:/mnt" \ 86272343Sngie -o "not-match:Disk quotas for .*: $" \ 87272343Sngie -o "match:Disk quotas for .*: none$" \ 88272343Sngie env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} 89272343Sngie done 90272343Sngie rump_quota_shutdown 91272343Sngie} 92