1227006Smarius# $NetBSD: t_clearquota.sh,v 1.3 2011/03/09 19:04:58 bouyer Exp $ 2227006Smarius# 3227006Smarius# Copyright (c) 2011 Manuel Bouyer 4227006Smarius# All rights reserved. 5227006Smarius# 6227006Smarius# Redistribution and use in source and binary forms, with or without 7227006Smarius# modification, are permitted provided that the following conditions 8227006Smarius# are met: 9227006Smarius# 1. Redistributions of source code must retain the above copyright 10227006Smarius# notice, this list of conditions and the following disclaimer. 11227006Smarius# 2. Redistributions in binary form must reproduce the above copyright 12227006Smarius# notice, this list of conditions and the following disclaimer in the 13227006Smarius# documentation and/or other materials provided with the distribution. 14227006Smarius# 15227006Smarius# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16227006Smarius# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17227006Smarius# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18227006Smarius# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19227006Smarius# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20227006Smarius# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21227006Smarius# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22227006Smarius# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23227006Smarius# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24227006Smarius# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25227006Smarius# POSSIBILITY OF SUCH DAMAGE. 26227006Smarius# 27227006Smarius 28227006Smariusfor e in le be; do 29227006Smarius for v in 1 2; do 30227006Smarius for q in "user" "group"; do 31227006Smarius test_case_root clear_${e}_${v}_${q} clear_quota \ 32227006Smarius "clear quota with ${q} enabled" -b ${e} ${v} ${q} 33227006Smarius done 34227006Smarius test_case_root clear_${e}_${v}_"both" clear_quota \ 35227006Smarius "clear quota with both enabled" -b ${e} ${v} "both" 36227006Smarius test_case_root clear_${e}_${v}_"both_log" clear_quota \ 37227006Smarius "clear quota for new id with both enabled, WAPBL" -bl ${e} ${v} "both" 38227006Smarius done 39227006Smariusdone 40227006Smarius 41227006Smariusclear_quota() 42227006Smarius{ 43227006Smarius create_ffs_server $* 44227006Smarius local q=$4 45227006Smarius local expect 46227006Smarius local fail 47227006Smarius local id=1 48227006Smarius 49227006Smarius case ${q} in 50227006Smarius user) 51227006Smarius expect=u 52227006Smarius fail=g 53227006Smarius ;; 54227006Smarius group) 55227006Smarius expect=g 56227006Smarius fail=u 57227006Smarius ;; 58227006Smarius both) 59227006Smarius expect="u g" 60227006Smarius fail="" 61227006Smarius ;; 62227006Smarius *) 63227006Smarius atf_fail "wrong quota type" 64227006Smarius ;; 65227006Smarius esac 66227006Smarius 67227006Smarius#set and check the expected quota 68227006Smarius for q in ${expect} ; do 69227006Smarius atf_check -s exit:0 \ 70227006Smarius env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \ 71227006Smarius -t 2W/3D ${id} 72227006Smarius atf_check -s exit:0 \ 73-o "match:/mnt 0 10 40960 2weeks 0 20 51200 3days" \ 74-o "match:Disk quotas for .*: $" \ 75 env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} 76 done 77#now clear the quotas 78 for q in ${expect} ; do 79 atf_check -s exit:0 \ 80 env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -c ${id} 81 done; 82 83#check that we do not get positive reply for any quota type 84 for q in u g ; do 85 atf_check -s exit:0 -o "not-match:/mnt" \ 86 -o "not-match:Disk quotas for .*: $" \ 87 -o "match:Disk quotas for .*: none$" \ 88 env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id} 89 done 90 rump_quota_shutdown 91} 92