quotas_common.sh revision 1.2
11.2Sbouyer# $NetBSD: quotas_common.sh,v 1.2 2011/03/06 17:08:40 bouyer Exp $ 
21.2Sbouyer
31.2Sbouyercreate_with_quotas()
41.2Sbouyer{
51.2Sbouyer	local endian=$1; shift
61.2Sbouyer	local vers=$1; shift
71.2Sbouyer	local type=$1; shift
81.2Sbouyer	local op;
91.2Sbouyer	if [ ${type} = "both" ]; then
101.2Sbouyer		op="-q user -q group"
111.2Sbouyer	else
121.2Sbouyer		op="-q ${type}"
131.2Sbouyer	fi
141.2Sbouyer	atf_check -o ignore -e ignore newfs ${op} \
151.2Sbouyer		-B ${endian} -O ${vers} -s 4000 -F ${IMG}
161.2Sbouyer}
171.2Sbouyer
181.2Sbouyercreate_with_quotas_server()
191.2Sbouyer{	
201.2Sbouyer	local sarg=$1; shift
211.2Sbouyer	create_with_quotas $*
221.2Sbouyer	atf_check -o ignore -e ignore $(atf_get_srcdir)/h_quota2_server \
231.2Sbouyer		${sarg} ${IMG} ${RUMP_SERVER}
241.2Sbouyer}
251.2Sbouyer
261.2Sbouyerrump_shutdown()
271.2Sbouyer{
281.2Sbouyer	atf_check -s exit:0 rump.halt
291.2Sbouyer# check that the quota inode creation didn't corrupt the filesystem
301.2Sbouyer	atf_check -s exit:0 -o "match:already clean" \
311.2Sbouyer		-o "match:Phase 6 - Check Quotas" \
321.2Sbouyer		fsck_ffs -nf -F ${IMG}
331.2Sbouyer}
341.2Sbouyer
351.2Sbouyer# from tests/ipf/h_common.sh via tests/sbin/resize_ffs
361.2Sbouyertest_case()
371.2Sbouyer{
381.2Sbouyer	local name="${1}"; shift
391.2Sbouyer	local check_function="${1}"; shift
401.2Sbouyer	local descr="${1}"; shift
411.2Sbouyer	
421.2Sbouyer	atf_test_case "${name}" cleanup
431.2Sbouyer
441.2Sbouyer	eval "${name}_head() { \
451.2Sbouyer		atf_set "descr" "${descr}"
461.2Sbouyer		atf_set "timeout" "60"
471.2Sbouyer	}"
481.2Sbouyer	eval "${name}_body() { \
491.2Sbouyer		${check_function} " "${@}" "; \
501.2Sbouyer	}"
511.2Sbouyer	eval "${name}_cleanup() { \
521.2Sbouyer		atf_check -s exit:1 -o ignore -e ignore rump.halt; \
531.2Sbouyer	}"
541.2Sbouyer	tests="${tests} ${name}"
551.2Sbouyer}
561.2Sbouyer
571.2Sbouyertest_case_root()
581.2Sbouyer{
591.2Sbouyer	local name="${1}"; shift
601.2Sbouyer	local check_function="${1}"; shift
611.2Sbouyer	local descr="${1}"; shift
621.2Sbouyer	
631.2Sbouyer	atf_test_case "${name}" cleanup
641.2Sbouyer
651.2Sbouyer	eval "${name}_head() { \
661.2Sbouyer		atf_set "descr" "${descr}"
671.2Sbouyer		atf_set "require.user" "root"
681.2Sbouyer		atf_set "timeout" "60"
691.2Sbouyer	}"
701.2Sbouyer	eval "${name}_body() { \
711.2Sbouyer		${check_function} " "${@}" "; \
721.2Sbouyer	}"
731.2Sbouyer	eval "${name}_cleanup() { \
741.2Sbouyer		atf_check -s exit:1 -o ignore -e ignore rump.halt; \
751.2Sbouyer	}"
761.2Sbouyer	tests="${tests} ${name}"
771.2Sbouyer}
781.2Sbouyer
791.2Sbouyeratf_init_test_cases()
801.2Sbouyer{
811.2Sbouyer	IMG=fsimage
821.2Sbouyer	DIR=target
831.2Sbouyer	RUMP_SOCKET=test
841.2Sbouyer	RUMP_SERVER=unix://${RUMP_SOCKET}
851.2Sbouyer	export RUMP_SERVER
861.2Sbouyer	for i in ${tests}; do
871.2Sbouyer		atf_add_test_case $i
881.2Sbouyer	done
891.2Sbouyer}
90