Home | History | Annotate | Line # | Download | only in ffs
t_getquota.sh revision 1.1.2.2
      1  1.1.2.2  bouyer # $NetBSD: t_getquota.sh,v 1.1.2.2 2011/01/30 11:33:33 bouyer Exp $ 
      2  1.1.2.1  bouyer #
      3  1.1.2.1  bouyer #  Copyright (c) 2011 Manuel Bouyer
      4  1.1.2.1  bouyer #  All rights reserved.
      5  1.1.2.1  bouyer # 
      6  1.1.2.1  bouyer #  Redistribution and use in source and binary forms, with or without
      7  1.1.2.1  bouyer #  modification, are permitted provided that the following conditions
      8  1.1.2.1  bouyer #  are met:
      9  1.1.2.1  bouyer #  1. Redistributions of source code must retain the above copyright
     10  1.1.2.1  bouyer #     notice, this list of conditions and the following disclaimer.
     11  1.1.2.1  bouyer #  2. Redistributions in binary form must reproduce the above copyright
     12  1.1.2.1  bouyer #     notice, this list of conditions and the following disclaimer in the
     13  1.1.2.1  bouyer #     documentation and/or other materials provided with the distribution.
     14  1.1.2.1  bouyer # 
     15  1.1.2.1  bouyer #  THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     16  1.1.2.1  bouyer #  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     17  1.1.2.1  bouyer #  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     18  1.1.2.1  bouyer #  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     19  1.1.2.1  bouyer #  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     20  1.1.2.1  bouyer #  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     21  1.1.2.1  bouyer #  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     22  1.1.2.1  bouyer #  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     23  1.1.2.1  bouyer #  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     24  1.1.2.1  bouyer #  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  1.1.2.1  bouyer #  POSSIBILITY OF SUCH DAMAGE.
     26  1.1.2.1  bouyer #
     27  1.1.2.1  bouyer 
     28  1.1.2.1  bouyer for e in le be; do
     29  1.1.2.1  bouyer   for v in 1 2; do
     30  1.1.2.1  bouyer     for q in "user" "group"; do
     31  1.1.2.1  bouyer       test_case get_${e}_${v}_${q} get_quota \
     32  1.1.2.1  bouyer 	 "get quota with ${q} enabled" ${e} ${v} ${q}
     33  1.1.2.1  bouyer     done
     34  1.1.2.1  bouyer     test_case get_${e}_${v}_"both" get_quota \
     35  1.1.2.1  bouyer 	 "get quota with both enabled" ${e} ${v} "both"
     36  1.1.2.1  bouyer   done
     37  1.1.2.1  bouyer done
     38  1.1.2.1  bouyer 
     39  1.1.2.1  bouyer get_quota()
     40  1.1.2.1  bouyer {
     41  1.1.2.1  bouyer 	create_with_quotas $*
     42  1.1.2.1  bouyer 	local q=$3
     43  1.1.2.1  bouyer 	local expect
     44  1.1.2.1  bouyer 	local fail
     45  1.1.2.1  bouyer 
     46  1.1.2.1  bouyer 	case ${q} in
     47  1.1.2.1  bouyer 	user)
     48  1.1.2.1  bouyer 		expect=u
     49  1.1.2.1  bouyer 		fail=g
     50  1.1.2.1  bouyer 		;;
     51  1.1.2.1  bouyer 	group)
     52  1.1.2.1  bouyer 		expect=g
     53  1.1.2.1  bouyer 		fail=u
     54  1.1.2.1  bouyer 		;;
     55  1.1.2.1  bouyer 	both)
     56  1.1.2.1  bouyer 		expect="u g"
     57  1.1.2.1  bouyer 		fail=""
     58  1.1.2.1  bouyer 		;;
     59  1.1.2.1  bouyer 	*)
     60  1.1.2.1  bouyer 		atf_fail "wrong quota type"
     61  1.1.2.1  bouyer 		;;
     62  1.1.2.1  bouyer 	esac
     63  1.1.2.1  bouyer 
     64  1.1.2.1  bouyer #check that we can get the expected quota
     65  1.1.2.1  bouyer 	for q in ${expect} ; do
     66  1.1.2.1  bouyer 		atf_check -s exit:0 \
     67  1.1.2.1  bouyer -o "match:/mnt        0        -        -               1       -       -" \
     68  1.1.2.1  bouyer -o "match:Disk quotas for .*: $" \
     69  1.1.2.1  bouyer 		    $(atf_get_srcdir)/rump_quota -${q} -v
     70  1.1.2.1  bouyer 		atf_check -s exit:0 \
     71  1.1.2.1  bouyer -o "match:--        0        -        -                1       -       -" \
     72  1.1.2.1  bouyer 		    $(atf_get_srcdir)/rump_repquota -${q} /mnt
     73  1.1.2.1  bouyer 	done
     74  1.1.2.1  bouyer 
     75  1.1.2.1  bouyer #check that we do not get positive reply for non-expected quota
     76  1.1.2.1  bouyer 	for q in ${fail} ; do
     77  1.1.2.1  bouyer 		atf_check -s exit:0 -o "not-match:/mnt" \
     78  1.1.2.1  bouyer 		    -o "not-match:Disk quotas for .*: $" \
     79  1.1.2.1  bouyer 		    -o "match:Disk quotas for .*: none$" \
     80  1.1.2.1  bouyer 		    $(atf_get_srcdir)/rump_quota -${q} -v
     81  1.1.2.1  bouyer 		atf_check -s exit:0 \
     82  1.1.2.1  bouyer -o "not-match:--        0        -        -                1       -       -" \
     83  1.1.2.1  bouyer 		    $(atf_get_srcdir)/rump_repquota -${q} /mnt
     84  1.1.2.1  bouyer 	done
     85  1.1.2.1  bouyer 	atf_check -s exit:0 rump.halt
     86  1.1.2.1  bouyer 	wait $!
     87  1.1.2.1  bouyer # check that the quota inode creation didn't corrupt the filesystem
     88  1.1.2.1  bouyer 	atf_check -s exit:0 -o "match:already clean" \
     89  1.1.2.1  bouyer 		-o "match:Phase 6 - Check Quotas" \
     90  1.1.2.1  bouyer 		fsck_ffs -nf -F ${IMG}
     91  1.1.2.1  bouyer }
     92