1# $NetBSD: t_clearquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ 2# 3# Copyright (c) 2011 Manuel Bouyer 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright 12# notice, this list of conditions and the following disclaimer in the 13# documentation and/or other materials provided with the distribution. 14# 15# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25# POSSIBILITY OF SUCH DAMAGE. 26# 27 28for e in le be; do 29 for v in 1 2; do 30 for q in "user" "group"; do 31 test_case_root clear_${e}_${v}_${q} clear_quota \ 32 "clear quota with ${q} enabled" -b ${e} ${v} ${q} 33 done 34 test_case_root clear_${e}_${v}_"both" clear_quota \ 35 "clear quota with both enabled" -b ${e} ${v} "both" 36 test_case_root clear_${e}_${v}_"both_log" clear_quota \ 37 "clear quota for new id with both enabled, WAPBL" -bl ${e} ${v} "both" 38 done 39done 40 41clear_quota() 42{ 43 create_ffs_server $* 44 local q=$4 45 local expect 46 local fail 47 local id=1 48 49 case ${q} in 50 user) 51 expect=u 52 fail=g 53 ;; 54 group) 55 expect=g 56 fail=u 57 ;; 58 both) 59 expect="u g" 60 fail="" 61 ;; 62 *) 63 atf_fail "wrong quota type" 64 ;; 65 esac 66 67#set and check the expected quota 68 for q in ${expect} ; do 69 atf_check -s exit:0 \ 70 env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \ 71 -t 2W/3D ${id} 72 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