xref: /minix3/tests/fs/ffs/ffs_common.sh (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc# $NetBSD: ffs_common.sh,v 1.2 2013/07/29 13:15:24 skrll Exp $
211be35a1SLionel Sambuc
311be35a1SLionel Sambuccreate_ffs()
411be35a1SLionel Sambuc{
511be35a1SLionel Sambuc	local endian=$1; shift
611be35a1SLionel Sambuc	local vers=$1; shift
711be35a1SLionel Sambuc	local type=$1; shift
811be35a1SLionel Sambuc	local op;
911be35a1SLionel Sambuc	if [ ${type} = "both" ]; then
1011be35a1SLionel Sambuc		op="-q user -q group"
1111be35a1SLionel Sambuc	else
1211be35a1SLionel Sambuc		op="-q ${type}"
1311be35a1SLionel Sambuc	fi
1411be35a1SLionel Sambuc	atf_check -o ignore -e ignore newfs ${op} \
1511be35a1SLionel Sambuc		-B ${endian} -O ${vers} -s 4000 -F ${IMG}
1611be35a1SLionel Sambuc}
1711be35a1SLionel Sambuc
1811be35a1SLionel Sambuccreate_ffs_server()
1911be35a1SLionel Sambuc{
2011be35a1SLionel Sambuc	local sarg=$1; shift
2111be35a1SLionel Sambuc	create_ffs $*
2211be35a1SLionel Sambuc	atf_check -o ignore -e ignore $(atf_get_srcdir)/h_ffs_server \
2311be35a1SLionel Sambuc		${sarg} ${IMG} ${RUMP_SERVER}
2411be35a1SLionel Sambuc}
2511be35a1SLionel Sambuc
2611be35a1SLionel Sambucrump_shutdown()
2711be35a1SLionel Sambuc{
2811be35a1SLionel Sambuc	for s in ${RUMP_SOCKETS_LIST}; do
2911be35a1SLionel Sambuc		atf_check -s exit:0 env RUMP_SERVER=unix://${s} rump.halt;
3011be35a1SLionel Sambuc	done
3111be35a1SLionel Sambuc# check that the quota inode creation didn't corrupt the filesystem
3211be35a1SLionel Sambuc	atf_check -s exit:0 -o "match:already clean" \
3311be35a1SLionel Sambuc		-o "match:Phase 6 - Check Quotas" \
3411be35a1SLionel Sambuc		fsck_ffs -nf -F ${IMG}
3511be35a1SLionel Sambuc}
3611be35a1SLionel Sambuc
3711be35a1SLionel Sambuc# from tests/ipf/h_common.sh via tests/sbin/resize_ffs
3811be35a1SLionel Sambuctest_case()
3911be35a1SLionel Sambuc{
4011be35a1SLionel Sambuc	local name="${1}"; shift
4111be35a1SLionel Sambuc	local check_function="${1}"; shift
4211be35a1SLionel Sambuc	local descr="${1}"; shift
4311be35a1SLionel Sambuc
4411be35a1SLionel Sambuc	atf_test_case "${name}" cleanup
4511be35a1SLionel Sambuc
4611be35a1SLionel Sambuc	eval "${name}_head() { \
4711be35a1SLionel Sambuc		atf_set "descr" "${descr}"
4811be35a1SLionel Sambuc		atf_set "timeout" "60"
4911be35a1SLionel Sambuc	}"
5011be35a1SLionel Sambuc	eval "${name}_body() { \
5111be35a1SLionel Sambuc		RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \
5211be35a1SLionel Sambuc		export RUMP_SERVER=unix://\${RUMP_SOCKET}; \
5311be35a1SLionel Sambuc		${check_function} " "${@}" "; \
5411be35a1SLionel Sambuc	}"
5511be35a1SLionel Sambuc	eval "${name}_cleanup() { \
5611be35a1SLionel Sambuc		for s in \${RUMP_SOCKETS_LIST}; do \
5711be35a1SLionel Sambuc			export RUMP_SERVER=unix://\${s}; \
5811be35a1SLionel Sambuc			atf_check -s exit:1 -o ignore -e ignore rump.halt; \
5911be35a1SLionel Sambuc		done; \
6011be35a1SLionel Sambuc	}"
6111be35a1SLionel Sambuc	tests="${tests} ${name}"
6211be35a1SLionel Sambuc}
6311be35a1SLionel Sambuc
6411be35a1SLionel Sambuctest_case_root()
6511be35a1SLionel Sambuc{
6611be35a1SLionel Sambuc	local name="${1}"; shift
6711be35a1SLionel Sambuc	local check_function="${1}"; shift
6811be35a1SLionel Sambuc	local descr="${1}"; shift
6911be35a1SLionel Sambuc
7011be35a1SLionel Sambuc	atf_test_case "${name}" cleanup
7111be35a1SLionel Sambuc
7211be35a1SLionel Sambuc	eval "${name}_head() { \
7311be35a1SLionel Sambuc		atf_set "descr" "${descr}"
7411be35a1SLionel Sambuc		atf_set "require.user" "root"
75*84d9c625SLionel Sambuc		atf_set "timeout" "360"
7611be35a1SLionel Sambuc	}"
7711be35a1SLionel Sambuc	eval "${name}_body() { \
7811be35a1SLionel Sambuc		RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \
7911be35a1SLionel Sambuc		export RUMP_SERVER=unix://\${RUMP_SOCKET}; \
8011be35a1SLionel Sambuc		${check_function} " "${@}" "; \
8111be35a1SLionel Sambuc	}"
8211be35a1SLionel Sambuc	eval "${name}_cleanup() { \
8311be35a1SLionel Sambuc		for s in \${RUMP_SOCKETS_LIST}; do \
8411be35a1SLionel Sambuc			export RUMP_SERVER=unix://\${s}; \
8511be35a1SLionel Sambuc			atf_check -s exit:1 -o ignore -e ignore rump.halt; \
8611be35a1SLionel Sambuc		done; \
8711be35a1SLionel Sambuc	}"
8811be35a1SLionel Sambuc	tests="${tests} ${name}"
8911be35a1SLionel Sambuc}
9011be35a1SLionel Sambuc
9111be35a1SLionel Sambucatf_init_test_cases()
9211be35a1SLionel Sambuc{
9311be35a1SLionel Sambuc	IMG=fsimage
9411be35a1SLionel Sambuc	DIR=target
9511be35a1SLionel Sambuc	RUMP_SOCKET=test;
9611be35a1SLionel Sambuc	for i in ${tests}; do
9711be35a1SLionel Sambuc		atf_add_test_case $i
9811be35a1SLionel Sambuc	done
9911be35a1SLionel Sambuc}
100