Home | History | Annotate | Line # | Download | only in ffs
      1  1.4  bouyer # $NetBSD: t_clearquota.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 be; do
     29  1.2  bouyer   for v in 1 2; do
     30  1.2  bouyer     for q in "user" "group"; do
     31  1.2  bouyer       test_case_root clear_${e}_${v}_${q} clear_quota \
     32  1.2  bouyer 	 "clear quota with ${q} enabled" -b ${e} ${v} ${q}
     33  1.2  bouyer     done
     34  1.2  bouyer     test_case_root clear_${e}_${v}_"both" clear_quota \
     35  1.2  bouyer 	 "clear quota with both enabled" -b ${e} ${v} "both"
     36  1.2  bouyer     test_case_root clear_${e}_${v}_"both_log" clear_quota \
     37  1.2  bouyer 	 "clear quota for new id with both enabled, WAPBL" -bl ${e} ${v} "both"
     38  1.2  bouyer   done
     39  1.2  bouyer done
     40  1.2  bouyer 
     41  1.2  bouyer clear_quota()
     42  1.2  bouyer {
     43  1.4  bouyer 	create_ffs_server $*
     44  1.2  bouyer 	local q=$4
     45  1.2  bouyer 	local expect
     46  1.2  bouyer 	local fail
     47  1.2  bouyer 	local id=1
     48  1.2  bouyer 
     49  1.2  bouyer 	case ${q} in
     50  1.2  bouyer 	user)
     51  1.2  bouyer 		expect=u
     52  1.2  bouyer 		fail=g
     53  1.2  bouyer 		;;
     54  1.2  bouyer 	group)
     55  1.2  bouyer 		expect=g
     56  1.2  bouyer 		fail=u
     57  1.2  bouyer 		;;
     58  1.2  bouyer 	both)
     59  1.2  bouyer 		expect="u g"
     60  1.2  bouyer 		fail=""
     61  1.2  bouyer 		;;
     62  1.2  bouyer 	*)
     63  1.2  bouyer 		atf_fail "wrong quota type"
     64  1.2  bouyer 		;;
     65  1.2  bouyer 	esac
     66  1.2  bouyer 
     67  1.2  bouyer #set and check the expected quota
     68  1.2  bouyer 	for q in ${expect} ; do
     69  1.2  bouyer 		atf_check -s exit:0 \
     70  1.3  bouyer 		   env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -s10k/20 -h40M/50k \
     71  1.2  bouyer 		   -t 2W/3D ${id}
     72  1.2  bouyer 		atf_check -s exit:0 \
     73  1.2  bouyer -o "match:/mnt        0       10    40960  2weeks       0      20   51200   3days" \
     74  1.2  bouyer -o "match:Disk quotas for .*: $" \
     75  1.3  bouyer 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id}
     76  1.2  bouyer 	done
     77  1.2  bouyer #now clear the quotas
     78  1.2  bouyer 	for q in ${expect} ; do
     79  1.2  bouyer 		atf_check -s exit:0 \
     80  1.3  bouyer 		   env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -$q -c ${id}
     81  1.2  bouyer 	done;
     82  1.2  bouyer 
     83  1.2  bouyer #check that we do not get positive reply for any quota type
     84  1.2  bouyer 	for q in u g ; do
     85  1.2  bouyer 		atf_check -s exit:0 -o "not-match:/mnt" \
     86  1.2  bouyer 		    -o "not-match:Disk quotas for .*: $" \
     87  1.2  bouyer 		    -o "match:Disk quotas for .*: none$" \
     88  1.3  bouyer 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id}
     89  1.2  bouyer 	done
     90  1.4  bouyer 	rump_quota_shutdown
     91  1.2  bouyer }
     92