11.5Sgson# $NetBSD: ffs_common.sh,v 1.5 2020/08/20 07:23:20 gson Exp $ 
21.1Sbouyer
31.1Sbouyercreate_ffs()
41.1Sbouyer{
51.1Sbouyer	local endian=$1; shift
61.1Sbouyer	local vers=$1; shift
71.1Sbouyer	local type=$1; shift
81.1Sbouyer	local op;
91.1Sbouyer	if [ ${type} = "both" ]; then
101.1Sbouyer		op="-q user -q group"
111.1Sbouyer	else
121.1Sbouyer		op="-q ${type}"
131.1Sbouyer	fi
141.1Sbouyer	atf_check -o ignore -e ignore newfs ${op} \
151.1Sbouyer		-B ${endian} -O ${vers} -s 4000 -F ${IMG}
161.1Sbouyer}
171.1Sbouyer
181.1Sbouyercreate_ffs_server()
191.1Sbouyer{	
201.1Sbouyer	local sarg=$1; shift
211.1Sbouyer	create_ffs $*
221.1Sbouyer	atf_check -o ignore -e ignore $(atf_get_srcdir)/h_ffs_server \
231.1Sbouyer		${sarg} ${IMG} ${RUMP_SERVER}
241.1Sbouyer}
251.1Sbouyer
261.1Sbouyer# from tests/ipf/h_common.sh via tests/sbin/resize_ffs
271.1Sbouyertest_case()
281.1Sbouyer{
291.1Sbouyer	local name="${1}"; shift
301.1Sbouyer	local check_function="${1}"; shift
311.1Sbouyer	local descr="${1}"; shift
321.1Sbouyer	
331.5Sgson	atf_test_case "${name}"
341.1Sbouyer
351.1Sbouyer	eval "${name}_head() { \
361.1Sbouyer		atf_set "descr" "${descr}"
371.3Sgson		atf_set "timeout" "120"
381.1Sbouyer	}"
391.1Sbouyer	eval "${name}_body() { \
401.1Sbouyer		RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \
411.1Sbouyer		export RUMP_SERVER=unix://\${RUMP_SOCKET}; \
421.1Sbouyer		${check_function} " "${@}" "; \
431.1Sbouyer	}"
441.1Sbouyer	tests="${tests} ${name}"
451.1Sbouyer}
461.1Sbouyer
471.1Sbouyertest_case_root()
481.1Sbouyer{
491.1Sbouyer	local name="${1}"; shift
501.1Sbouyer	local check_function="${1}"; shift
511.1Sbouyer	local descr="${1}"; shift
521.1Sbouyer	
531.5Sgson	atf_test_case "${name}"
541.1Sbouyer
551.1Sbouyer	eval "${name}_head() { \
561.1Sbouyer		atf_set "descr" "${descr}"
571.1Sbouyer		atf_set "require.user" "root"
581.2Sskrll		atf_set "timeout" "360"
591.1Sbouyer	}"
601.1Sbouyer	eval "${name}_body() { \
611.1Sbouyer		RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \
621.1Sbouyer		export RUMP_SERVER=unix://\${RUMP_SOCKET}; \
631.1Sbouyer		${check_function} " "${@}" "; \
641.1Sbouyer	}"
651.1Sbouyer	tests="${tests} ${name}"
661.1Sbouyer}
671.1Sbouyer
681.1Sbouyeratf_init_test_cases()
691.1Sbouyer{
701.1Sbouyer	IMG=fsimage
711.1Sbouyer	DIR=target
721.1Sbouyer	RUMP_SOCKET=test;
731.1Sbouyer	for i in ${tests}; do
741.1Sbouyer		atf_add_test_case $i
751.1Sbouyer	done
761.1Sbouyer}
77