quotas_common.sh revision 1.3
11.3Sbouyer# $NetBSD: quotas_common.sh,v 1.3 2011/03/12 13:43:58 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.3Sbouyer	for s in ${RUMP_SOCKETS_LIST}; do
291.3Sbouyer		atf_check -s exit:0 env RUMP_SERVER=unix://${s} rump.halt;
301.3Sbouyer	done
311.2Sbouyer# check that the quota inode creation didn't corrupt the filesystem
321.2Sbouyer	atf_check -s exit:0 -o "match:already clean" \
331.2Sbouyer		-o "match:Phase 6 - Check Quotas" \
341.2Sbouyer		fsck_ffs -nf -F ${IMG}
351.2Sbouyer}
361.2Sbouyer
371.2Sbouyer# from tests/ipf/h_common.sh via tests/sbin/resize_ffs
381.2Sbouyertest_case()
391.2Sbouyer{
401.2Sbouyer	local name="${1}"; shift
411.2Sbouyer	local check_function="${1}"; shift
421.2Sbouyer	local descr="${1}"; shift
431.2Sbouyer	
441.2Sbouyer	atf_test_case "${name}" cleanup
451.2Sbouyer
461.2Sbouyer	eval "${name}_head() { \
471.2Sbouyer		atf_set "descr" "${descr}"
481.2Sbouyer		atf_set "timeout" "60"
491.2Sbouyer	}"
501.2Sbouyer	eval "${name}_body() { \
511.3Sbouyer		RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \
521.3Sbouyer		export RUMP_SERVER=unix://\${RUMP_SOCKET}; \
531.2Sbouyer		${check_function} " "${@}" "; \
541.2Sbouyer	}"
551.2Sbouyer	eval "${name}_cleanup() { \
561.3Sbouyer		for s in \${RUMP_SOCKETS_LIST}; do \
571.3Sbouyer			export RUMP_SERVER=unix://\${s}; \
581.3Sbouyer			atf_check -s exit:1 -o ignore -e ignore rump.halt; \
591.3Sbouyer		done; \
601.2Sbouyer	}"
611.2Sbouyer	tests="${tests} ${name}"
621.2Sbouyer}
631.2Sbouyer
641.2Sbouyertest_case_root()
651.2Sbouyer{
661.2Sbouyer	local name="${1}"; shift
671.2Sbouyer	local check_function="${1}"; shift
681.2Sbouyer	local descr="${1}"; shift
691.2Sbouyer	
701.2Sbouyer	atf_test_case "${name}" cleanup
711.2Sbouyer
721.2Sbouyer	eval "${name}_head() { \
731.2Sbouyer		atf_set "descr" "${descr}"
741.2Sbouyer		atf_set "require.user" "root"
751.2Sbouyer		atf_set "timeout" "60"
761.2Sbouyer	}"
771.2Sbouyer	eval "${name}_body() { \
781.3Sbouyer		RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \
791.3Sbouyer		export RUMP_SERVER=unix://\${RUMP_SOCKET}; \
801.2Sbouyer		${check_function} " "${@}" "; \
811.2Sbouyer	}"
821.2Sbouyer	eval "${name}_cleanup() { \
831.3Sbouyer		for s in \${RUMP_SOCKETS_LIST}; do \
841.3Sbouyer			export RUMP_SERVER=unix://\${s}; \
851.3Sbouyer			atf_check -s exit:1 -o ignore -e ignore rump.halt; \
861.3Sbouyer		done; \
871.2Sbouyer	}"
881.2Sbouyer	tests="${tests} ${name}"
891.2Sbouyer}
901.2Sbouyer
911.2Sbouyeratf_init_test_cases()
921.2Sbouyer{
931.2Sbouyer	IMG=fsimage
941.2Sbouyer	DIR=target
951.3Sbouyer	RUMP_SOCKET=test;
961.2Sbouyer	for i in ${tests}; do
971.2Sbouyer		atf_add_test_case $i
981.2Sbouyer	done
991.2Sbouyer}
100