Home | History | Annotate | Line # | Download | only in ffs
t_getquota.sh revision 1.3.4.1
      1  1.3.4.1    yamt # $NetBSD: t_getquota.sh,v 1.3.4.1 2012/04/17 00:09:03 yamt 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 get_${e}_${v}_${q} get_quota \
     32      1.2  bouyer 	 "get quota with ${q} enabled" -b ${e} ${v} ${q}
     33      1.2  bouyer     done
     34      1.2  bouyer     test_case get_${e}_${v}_"both" get_quota \
     35      1.2  bouyer 	 "get quota with both enabled" -b ${e} ${v} "both"
     36      1.2  bouyer   done
     37      1.2  bouyer done
     38      1.2  bouyer 
     39      1.2  bouyer get_quota()
     40      1.2  bouyer {
     41  1.3.4.1    yamt 	create_ffs_server $*
     42      1.2  bouyer 	local q=$4
     43      1.2  bouyer 	local expect
     44      1.2  bouyer 	local fail
     45      1.2  bouyer 
     46      1.2  bouyer 	case ${q} in
     47      1.2  bouyer 	user)
     48      1.2  bouyer 		expect=u
     49      1.2  bouyer 		fail=g
     50      1.2  bouyer 		;;
     51      1.2  bouyer 	group)
     52      1.2  bouyer 		expect=g
     53      1.2  bouyer 		fail=u
     54      1.2  bouyer 		;;
     55      1.2  bouyer 	both)
     56      1.2  bouyer 		expect="u g"
     57      1.2  bouyer 		fail=""
     58      1.2  bouyer 		;;
     59      1.2  bouyer 	*)
     60      1.2  bouyer 		atf_fail "wrong quota type"
     61      1.2  bouyer 		;;
     62      1.2  bouyer 	esac
     63      1.2  bouyer 
     64      1.2  bouyer #check that we can get the expected quota
     65      1.2  bouyer 	for q in ${expect} ; do
     66      1.2  bouyer 		atf_check -s exit:0 \
     67      1.2  bouyer -o "match:/mnt        0        -        -   7days       1       -       -   7days" \
     68      1.2  bouyer -o "match:Disk quotas for .*: $" \
     69      1.3  bouyer 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v
     70      1.2  bouyer 		atf_check -s exit:0 \
     71      1.2  bouyer -o "match:--        0        -        -                1       -       -" \
     72      1.2  bouyer -o "not-match:\+\+"							  \
     73      1.3  bouyer 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt
     74      1.2  bouyer 	done
     75      1.2  bouyer 
     76      1.2  bouyer #check that we do not get positive reply for non-expected quota
     77      1.2  bouyer 	for q in ${fail} ; do
     78      1.2  bouyer 		atf_check -s exit:0 -o "not-match:/mnt" \
     79      1.2  bouyer 		    -o "not-match:Disk quotas for .*: $" \
     80      1.2  bouyer 		    -o "match:Disk quotas for .*: none$" \
     81      1.3  bouyer 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v
     82      1.2  bouyer 		atf_check -s exit:0 \
     83      1.2  bouyer -o "not-match:--        0        -        -                1       -       -" \
     84      1.3  bouyer 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt
     85      1.2  bouyer 	done
     86  1.3.4.1    yamt 	rump_quota_shutdown
     87      1.2  bouyer }
     88      1.2  bouyer 
     89      1.2  bouyer quota_walk_list()
     90      1.2  bouyer {
     91  1.3.4.1    yamt 	create_ffs_server $*
     92      1.2  bouyer 	local q=$4
     93      1.2  bouyer 	local expect
     94      1.2  bouyer 
     95      1.2  bouyer 	case ${q} in
     96      1.2  bouyer 	user)
     97      1.2  bouyer 		expect=u
     98      1.2  bouyer 		fail=g
     99      1.2  bouyer 		;;
    100      1.2  bouyer 	group)
    101      1.2  bouyer 		expect=g
    102      1.2  bouyer 		fail=u
    103      1.2  bouyer 		;;
    104      1.2  bouyer 	both)
    105      1.2  bouyer 		expect="u g"
    106      1.2  bouyer 		fail=""
    107      1.2  bouyer 		;;
    108      1.2  bouyer 	*)
    109      1.2  bouyer 		atf_fail "wrong quota type"
    110      1.2  bouyer 		;;
    111      1.2  bouyer 	esac
    112      1.2  bouyer }
    113