Module Name:    src
Committed By:   bouyer
Date:           Wed Jan 18 20:51:23 UTC 2012

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/tests/fs/ffs: Makefile quotas_common.sh t_clearquota.sh
            t_getquota.sh t_miscquota.sh t_quotalimit.sh t_setquota.sh
Added Files:
        src/tests/fs/ffs: ffs_common.sh h_ffs_server.c
Removed Files:
        src/tests/fs/ffs: h_quota2_server.c

Log Message:
Make parts of the quota tests useable for more than quotas:
- rename h_quota2_server to h_ffs_server, there's nothing about quotas
  in there.
- extract non-quota parts of quotas_common.sh to ffs_common.sh


To generate a diff of this commit:
cvs rdiff -u -r1.433 -r1.434 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.16 -r1.17 src/tests/fs/ffs/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/fs/ffs/ffs_common.sh \
    src/tests/fs/ffs/h_ffs_server.c
cvs rdiff -u -r1.2 -r0 src/tests/fs/ffs/h_quota2_server.c
cvs rdiff -u -r1.3 -r1.4 src/tests/fs/ffs/quotas_common.sh \
    src/tests/fs/ffs/t_clearquota.sh src/tests/fs/ffs/t_getquota.sh \
    src/tests/fs/ffs/t_miscquota.sh src/tests/fs/ffs/t_quotalimit.sh \
    src/tests/fs/ffs/t_setquota.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.433 src/distrib/sets/lists/tests/mi:1.434
--- src/distrib/sets/lists/tests/mi:1.433	Tue Dec 27 17:13:10 2011
+++ src/distrib/sets/lists/tests/mi	Wed Jan 18 20:51:23 2012
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.433 2011/12/27 17:13:10 pgoyette Exp $
+# $NetBSD: mi,v 1.434 2012/01/18 20:51:23 bouyer Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -227,7 +227,8 @@
 ./usr/libdata/debug/usr/tests/dev/sysmon					tests-fs-debug
 ./usr/libdata/debug/usr/tests/dev/sysmon/t_swwdog.debug			tests-fs-debug		debug,atf
 ./usr/libdata/debug/usr/tests/fs/ffs					tests-fs-debug
-./usr/libdata/debug/usr/tests/fs/ffs/h_quota2_server.debug		tests-fs-debug		debug,atf
+./usr/libdata/debug/usr/tests/fs/ffs/h_ffs_server.debug			tests-fs-debug		debug,atf
+./usr/libdata/debug/usr/tests/fs/ffs/h_quota2_server.debug		tests-obsolete		obsolete
 ./usr/libdata/debug/usr/tests/fs/ffs/h_quota2_tests.debug		tests-fs-debug		debug,atf
 ./usr/libdata/debug/usr/tests/fs/ffs/t_fifos.debug			tests-fs-debug		debug,atf
 ./usr/libdata/debug/usr/tests/fs/ffs/t_mount.debug			tests-fs-debug		debug,atf
@@ -1410,7 +1411,8 @@
 ./usr/tests/fs/h_funcs.subr			tests-fs-tests		atf
 ./usr/tests/fs/ffs				tests-fs-tests
 ./usr/tests/fs/ffs/Atffile			tests-fs-tests		atf
-./usr/tests/fs/ffs/h_quota2_server		tests-fs-tests		atf
+./usr/tests/fs/ffs/h_ffs_server			tests-fs-tests		atf
+./usr/tests/fs/ffs/h_quota2_server		tests-obsolete		obsolete
 ./usr/tests/fs/ffs/h_quota2_tests		tests-fs-tests		atf
 ./usr/tests/fs/ffs/rump_edquota			tests-obsolete		obsolete
 ./usr/tests/fs/ffs/rump_quota			tests-obsolete		obsolete

Index: src/tests/fs/ffs/Makefile
diff -u src/tests/fs/ffs/Makefile:1.16 src/tests/fs/ffs/Makefile:1.17
--- src/tests/fs/ffs/Makefile:1.16	Wed Mar  9 20:13:47 2011
+++ src/tests/fs/ffs/Makefile	Wed Jan 18 20:51:23 2012
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.16 2011/03/09 20:13:47 tron Exp $
+#	$NetBSD: Makefile,v 1.17 2012/01/18 20:51:23 bouyer Exp $
 #
 
 .include <bsd.own.mk>
@@ -6,10 +6,10 @@
 TESTSDIR=	${TESTSBASE}/fs/ffs
 WARNS=		4
 
-PROGS=			h_quota2_server h_quota2_tests
-SRCS.h_quota2_server=	h_quota2_server.c
-MAN.h_quota2_server=	# empty
-BINDIR.h_quota2_server=	${TESTSDIR}
+PROGS=			h_ffs_server h_quota2_tests
+SRCS.h_ffs_server=	h_ffs_server.c
+MAN.h_ffs_server=	# empty
+BINDIR.h_ffs_server=	${TESTSDIR}
 
 SRCS.h_quota2_tests=	h_quota2_tests.c
 MAN.h_quota2_tests=	# empty
@@ -17,7 +17,7 @@ BINDIR.h_quota2_tests=	${TESTSDIR}
 
 .for name in t_getquota t_setquota t_quotalimit t_clearquota t_miscquota
 TESTS_SH+=	${name}
-TESTS_SH_SRC_${name}=	quotas_common.sh ${name}.sh
+TESTS_SH_SRC_${name}=	ffs_common.sh quotas_common.sh ${name}.sh
 .endfor
 
 TESTS_C+=	t_fifos

Index: src/tests/fs/ffs/quotas_common.sh
diff -u src/tests/fs/ffs/quotas_common.sh:1.3 src/tests/fs/ffs/quotas_common.sh:1.4
--- src/tests/fs/ffs/quotas_common.sh:1.3	Sat Mar 12 13:43:58 2011
+++ src/tests/fs/ffs/quotas_common.sh	Wed Jan 18 20:51:23 2012
@@ -1,29 +1,6 @@
-# $NetBSD: quotas_common.sh,v 1.3 2011/03/12 13:43:58 bouyer Exp $ 
+# $NetBSD: quotas_common.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ 
 
-create_with_quotas()
-{
-	local endian=$1; shift
-	local vers=$1; shift
-	local type=$1; shift
-	local op;
-	if [ ${type} = "both" ]; then
-		op="-q user -q group"
-	else
-		op="-q ${type}"
-	fi
-	atf_check -o ignore -e ignore newfs ${op} \
-		-B ${endian} -O ${vers} -s 4000 -F ${IMG}
-}
-
-create_with_quotas_server()
-{	
-	local sarg=$1; shift
-	create_with_quotas $*
-	atf_check -o ignore -e ignore $(atf_get_srcdir)/h_quota2_server \
-		${sarg} ${IMG} ${RUMP_SERVER}
-}
-
-rump_shutdown()
+rump_quota_shutdown()
 {
 	for s in ${RUMP_SOCKETS_LIST}; do
 		atf_check -s exit:0 env RUMP_SERVER=unix://${s} rump.halt;
@@ -33,67 +10,3 @@ rump_shutdown()
 		-o "match:Phase 6 - Check Quotas" \
 		fsck_ffs -nf -F ${IMG}
 }
-
-# from tests/ipf/h_common.sh via tests/sbin/resize_ffs
-test_case()
-{
-	local name="${1}"; shift
-	local check_function="${1}"; shift
-	local descr="${1}"; shift
-	
-	atf_test_case "${name}" cleanup
-
-	eval "${name}_head() { \
-		atf_set "descr" "${descr}"
-		atf_set "timeout" "60"
-	}"
-	eval "${name}_body() { \
-		RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \
-		export RUMP_SERVER=unix://\${RUMP_SOCKET}; \
-		${check_function} " "${@}" "; \
-	}"
-	eval "${name}_cleanup() { \
-		for s in \${RUMP_SOCKETS_LIST}; do \
-			export RUMP_SERVER=unix://\${s}; \
-			atf_check -s exit:1 -o ignore -e ignore rump.halt; \
-		done; \
-	}"
-	tests="${tests} ${name}"
-}
-
-test_case_root()
-{
-	local name="${1}"; shift
-	local check_function="${1}"; shift
-	local descr="${1}"; shift
-	
-	atf_test_case "${name}" cleanup
-
-	eval "${name}_head() { \
-		atf_set "descr" "${descr}"
-		atf_set "require.user" "root"
-		atf_set "timeout" "60"
-	}"
-	eval "${name}_body() { \
-		RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \
-		export RUMP_SERVER=unix://\${RUMP_SOCKET}; \
-		${check_function} " "${@}" "; \
-	}"
-	eval "${name}_cleanup() { \
-		for s in \${RUMP_SOCKETS_LIST}; do \
-			export RUMP_SERVER=unix://\${s}; \
-			atf_check -s exit:1 -o ignore -e ignore rump.halt; \
-		done; \
-	}"
-	tests="${tests} ${name}"
-}
-
-atf_init_test_cases()
-{
-	IMG=fsimage
-	DIR=target
-	RUMP_SOCKET=test;
-	for i in ${tests}; do
-		atf_add_test_case $i
-	done
-}
Index: src/tests/fs/ffs/t_clearquota.sh
diff -u src/tests/fs/ffs/t_clearquota.sh:1.3 src/tests/fs/ffs/t_clearquota.sh:1.4
--- src/tests/fs/ffs/t_clearquota.sh:1.3	Wed Mar  9 19:04:58 2011
+++ src/tests/fs/ffs/t_clearquota.sh	Wed Jan 18 20:51:23 2012
@@ -1,4 +1,4 @@
-# $NetBSD: t_clearquota.sh,v 1.3 2011/03/09 19:04:58 bouyer Exp $ 
+# $NetBSD: t_clearquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ 
 #
 #  Copyright (c) 2011 Manuel Bouyer
 #  All rights reserved.
@@ -40,7 +40,7 @@ done
 
 clear_quota()
 {
-	create_with_quotas_server $*
+	create_ffs_server $*
 	local q=$4
 	local expect
 	local fail
@@ -87,5 +87,5 @@ clear_quota()
 		    -o "match:Disk quotas for .*: none$" \
 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id}
 	done
-	rump_shutdown
+	rump_quota_shutdown
 }
Index: src/tests/fs/ffs/t_getquota.sh
diff -u src/tests/fs/ffs/t_getquota.sh:1.3 src/tests/fs/ffs/t_getquota.sh:1.4
--- src/tests/fs/ffs/t_getquota.sh:1.3	Wed Mar  9 19:04:58 2011
+++ src/tests/fs/ffs/t_getquota.sh	Wed Jan 18 20:51:23 2012
@@ -1,4 +1,4 @@
-# $NetBSD: t_getquota.sh,v 1.3 2011/03/09 19:04:58 bouyer Exp $ 
+# $NetBSD: t_getquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ 
 #
 #  Copyright (c) 2011 Manuel Bouyer
 #  All rights reserved.
@@ -38,7 +38,7 @@ done
 
 get_quota()
 {
-	create_with_quotas_server $*
+	create_ffs_server $*
 	local q=$4
 	local expect
 	local fail
@@ -83,12 +83,12 @@ get_quota()
 -o "not-match:--        0        -        -                1       -       -" \
 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt
 	done
-	rump_shutdown
+	rump_quota_shutdown
 }
 
 quota_walk_list()
 {
-	create_with_quotas_server $*
+	create_ffs_server $*
 	local q=$4
 	local expect
 
Index: src/tests/fs/ffs/t_miscquota.sh
diff -u src/tests/fs/ffs/t_miscquota.sh:1.3 src/tests/fs/ffs/t_miscquota.sh:1.4
--- src/tests/fs/ffs/t_miscquota.sh:1.3	Wed Mar  9 19:04:58 2011
+++ src/tests/fs/ffs/t_miscquota.sh	Wed Jan 18 20:51:23 2012
@@ -1,4 +1,4 @@
-# $NetBSD: t_miscquota.sh,v 1.3 2011/03/09 19:04:58 bouyer Exp $ 
+# $NetBSD: t_miscquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ 
 #
 #  Copyright (c) 2011 Manuel Bouyer
 #  All rights reserved.
@@ -55,7 +55,7 @@ test_case log_unlink_remount quota_log \
 
 quota_walk_list()
 {
-	create_with_quotas_server $*
+	create_ffs_server $*
 	local q=$4
 	local expect
 
@@ -84,13 +84,13 @@ quota_walk_list()
 	# do a repquota
 	atf_check -s exit:0 -o 'match:<integer>0x64000' \
 	    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -x -${expect} /mnt
-	rump_shutdown
+	rump_quota_shutdown
 }
 
 quota_snap()
 {
 	local flag=$1; shift
-	create_with_quotas $*
+	create_ffs $*
 	local q=$3
 	local expect
 
@@ -124,13 +124,13 @@ quota_snap()
 	    -o 'match:-        -  7days         5       -       -  7days' \
 	    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -av
 	#shutdown and check filesystem
-	rump_shutdown
+	rump_quota_shutdown
 }
 
 quota_log()
 {
 	local srv2args=$1; shift
-	create_with_quotas $*
+	create_ffs $*
 	local q=$3
 	local expect
 
@@ -160,5 +160,5 @@ quota_log()
 	atf_check -o ignore -e ignore $(atf_get_srcdir)/h_quota2_tests \
 	    ${srv2args} -b 5 ${IMG} ${RUMP_SERVER}
 	#shutdown and check filesystem
-	rump_shutdown
+	rump_quota_shutdown
 }
Index: src/tests/fs/ffs/t_quotalimit.sh
diff -u src/tests/fs/ffs/t_quotalimit.sh:1.3 src/tests/fs/ffs/t_quotalimit.sh:1.4
--- src/tests/fs/ffs/t_quotalimit.sh:1.3	Wed Mar  9 19:04:58 2011
+++ src/tests/fs/ffs/t_quotalimit.sh	Wed Jan 18 20:51:23 2012
@@ -1,4 +1,4 @@
-# $NetBSD: t_quotalimit.sh,v 1.3 2011/03/09 19:04:58 bouyer Exp $ 
+# $NetBSD: t_quotalimit.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ 
 #
 #  Copyright (c) 2011 Manuel Bouyer
 #  All rights reserved.
@@ -54,7 +54,7 @@ done
 
 limit_quota()
 {
-	create_with_quotas_server $*
+	create_ffs_server $*
 	local q=$4
 	local expect
 	local id=1
@@ -96,12 +96,12 @@ limit_quota()
 		    -o match:'daemon    \+-        3        2        3    2:0         2       4       6' \
 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
 	done
-	rump_shutdown
+	rump_quota_shutdown
 }
 
 limit_softquota()
 {
-	create_with_quotas_server $*
+	create_ffs_server $*
 	local q=$4
 	local expect
 	local id=1
@@ -143,12 +143,12 @@ limit_softquota()
 		    -o match:'daemon    \+-        2        2        3   none         2       4       6' \
 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
 	done
-	rump_shutdown
+	rump_quota_shutdown
 }
 
 limit_iquota()
 {
-	create_with_quotas_server $*
+	create_ffs_server $*
 	local q=$4
 	local expect
 	local id=1
@@ -190,12 +190,12 @@ limit_iquota()
 		    -o match:'daemon    -\+        3     2048     3072                6       4       6    2:0' \
 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
 	done
-	rump_shutdown
+	rump_quota_shutdown
 }
 
 limit_softiquota()
 {
-	create_with_quotas_server $*
+	create_ffs_server $*
 	local q=$4
 	local expect
 	local id=1
@@ -237,12 +237,12 @@ limit_softiquota()
 		    -o match:'daemon    -\+        2     2048     3072                5       4       6   none' \
 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
 	done
-	rump_shutdown
+	rump_quota_shutdown
 }
 
 inherit_defaultquota()
 {
-	create_with_quotas_server $*
+	create_ffs_server $*
 	local q=$4
 	local expect
 	local id=1
@@ -289,12 +289,12 @@ inherit_defaultquota()
 		    -o match:'daemon    \+-        3        2        3    2:0         2       4       6' \
 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
 	done
-	rump_shutdown
+	rump_quota_shutdown
 }
 
 inherit_defaultiquota()
 {
-	create_with_quotas_server $*
+	create_ffs_server $*
 	local q=$4
 	local expect
 	local id=1
@@ -341,5 +341,5 @@ inherit_defaultiquota()
 		    -o match:'daemon    -\+        3     2048     3072                6       4       6    2:0' \
 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -$q /mnt
 	done
-	rump_shutdown
+	rump_quota_shutdown
 }
Index: src/tests/fs/ffs/t_setquota.sh
diff -u src/tests/fs/ffs/t_setquota.sh:1.3 src/tests/fs/ffs/t_setquota.sh:1.4
--- src/tests/fs/ffs/t_setquota.sh:1.3	Wed Mar  9 19:04:58 2011
+++ src/tests/fs/ffs/t_setquota.sh	Wed Jan 18 20:51:23 2012
@@ -1,4 +1,4 @@
-# $NetBSD: t_setquota.sh,v 1.3 2011/03/09 19:04:58 bouyer Exp $ 
+# $NetBSD: t_setquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ 
 #
 #  Copyright (c) 2011 Manuel Bouyer
 #  All rights reserved.
@@ -48,7 +48,7 @@ done
 
 set_quota()
 {
-	create_with_quotas_server $*
+	create_ffs_server $*
 	local q=$4
 	local expect
 	local fail
@@ -99,12 +99,12 @@ set_quota()
 -o "not-match:--        0        -        -" \
 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -${q} /mnt
 	done
-	rump_shutdown
+	rump_quota_shutdown
 }
 
 set_quota_new()
 {
-	create_with_quotas_server $*
+	create_ffs_server $*
 	local q=$4
 	local expect
 	local fail
@@ -149,12 +149,12 @@ set_quota_new()
 		    -o "match:Disk quotas for .*: none$" \
 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id}
 	done
-	rump_shutdown
+	rump_quota_shutdown
 }
 
 set_quota_default()
 {
-	create_with_quotas_server $*
+	create_ffs_server $*
 	local q=$4
 	local expect
 	local fail
@@ -199,5 +199,5 @@ set_quota_default()
 		    -o "match:Default (user|group) disk quotas: none$" \
 		    env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quota -${q} -v ${id}
 	done
-	rump_shutdown
+	rump_quota_shutdown
 }

Added files:

Index: src/tests/fs/ffs/ffs_common.sh
diff -u /dev/null src/tests/fs/ffs/ffs_common.sh:1.1
--- /dev/null	Wed Jan 18 20:51:23 2012
+++ src/tests/fs/ffs/ffs_common.sh	Wed Jan 18 20:51:23 2012
@@ -0,0 +1,99 @@
+# $NetBSD: ffs_common.sh,v 1.1 2012/01/18 20:51:23 bouyer Exp $ 
+
+create_ffs()
+{
+	local endian=$1; shift
+	local vers=$1; shift
+	local type=$1; shift
+	local op;
+	if [ ${type} = "both" ]; then
+		op="-q user -q group"
+	else
+		op="-q ${type}"
+	fi
+	atf_check -o ignore -e ignore newfs ${op} \
+		-B ${endian} -O ${vers} -s 4000 -F ${IMG}
+}
+
+create_ffs_server()
+{	
+	local sarg=$1; shift
+	create_ffs $*
+	atf_check -o ignore -e ignore $(atf_get_srcdir)/h_ffs_server \
+		${sarg} ${IMG} ${RUMP_SERVER}
+}
+
+rump_shutdown()
+{
+	for s in ${RUMP_SOCKETS_LIST}; do
+		atf_check -s exit:0 env RUMP_SERVER=unix://${s} rump.halt;
+	done
+# check that the quota inode creation didn't corrupt the filesystem
+	atf_check -s exit:0 -o "match:already clean" \
+		-o "match:Phase 6 - Check Quotas" \
+		fsck_ffs -nf -F ${IMG}
+}
+
+# from tests/ipf/h_common.sh via tests/sbin/resize_ffs
+test_case()
+{
+	local name="${1}"; shift
+	local check_function="${1}"; shift
+	local descr="${1}"; shift
+	
+	atf_test_case "${name}" cleanup
+
+	eval "${name}_head() { \
+		atf_set "descr" "${descr}"
+		atf_set "timeout" "60"
+	}"
+	eval "${name}_body() { \
+		RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \
+		export RUMP_SERVER=unix://\${RUMP_SOCKET}; \
+		${check_function} " "${@}" "; \
+	}"
+	eval "${name}_cleanup() { \
+		for s in \${RUMP_SOCKETS_LIST}; do \
+			export RUMP_SERVER=unix://\${s}; \
+			atf_check -s exit:1 -o ignore -e ignore rump.halt; \
+		done; \
+	}"
+	tests="${tests} ${name}"
+}
+
+test_case_root()
+{
+	local name="${1}"; shift
+	local check_function="${1}"; shift
+	local descr="${1}"; shift
+	
+	atf_test_case "${name}" cleanup
+
+	eval "${name}_head() { \
+		atf_set "descr" "${descr}"
+		atf_set "require.user" "root"
+		atf_set "timeout" "60"
+	}"
+	eval "${name}_body() { \
+		RUMP_SOCKETS_LIST=\${RUMP_SOCKET}; \
+		export RUMP_SERVER=unix://\${RUMP_SOCKET}; \
+		${check_function} " "${@}" "; \
+	}"
+	eval "${name}_cleanup() { \
+		for s in \${RUMP_SOCKETS_LIST}; do \
+			export RUMP_SERVER=unix://\${s}; \
+			atf_check -s exit:1 -o ignore -e ignore rump.halt; \
+		done; \
+	}"
+	tests="${tests} ${name}"
+}
+
+atf_init_test_cases()
+{
+	IMG=fsimage
+	DIR=target
+	RUMP_SOCKET=test;
+	for i in ${tests}; do
+		atf_add_test_case $i
+	done
+}
Index: src/tests/fs/ffs/h_ffs_server.c
diff -u /dev/null src/tests/fs/ffs/h_ffs_server.c:1.1
--- /dev/null	Wed Jan 18 20:51:23 2012
+++ src/tests/fs/ffs/h_ffs_server.c	Wed Jan 18 20:51:23 2012
@@ -0,0 +1,115 @@
+/*	$NetBSD: h_ffs_server.c,v 1.1 2012/01/18 20:51:23 bouyer Exp $	*/
+
+/*
+ * rump server for advanced quota tests
+ */
+
+#include "../common/h_fsmacros.h"
+
+#include <err.h>
+#include <semaphore.h>
+#include <sys/types.h>
+#include <sys/mount.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <ufs/ufs/ufsmount.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "../../h_macros.h"
+
+int background = 0;
+
+static void
+usage(void)
+{
+	fprintf(stderr, "usage: %s [-b] [-l] diskimage bindurl\n",
+	    getprogname());
+	exit(1);
+}
+
+static void
+die(const char *reason, int error)
+{
+
+	warnx("%s: %s", reason, strerror(error));
+	if (background)
+		rump_daemonize_done(error);
+	exit(1);
+}
+
+static sem_t sigsem;
+static void
+sigreboot(int sig)
+{
+
+	sem_post(&sigsem);
+}
+
+int 
+main(int argc, char **argv)
+{
+	int error;
+	struct ufs_args uargs;
+	const char *filename;
+	const char *serverurl;
+	int log = 0;
+	int ch;
+
+	while ((ch = getopt(argc, argv, "bl")) != -1) {
+		switch(ch) {
+		case 'b':
+			background = 1;
+			break;
+		case 'l':
+			log = 1;
+			break;
+		default:
+			usage();
+		}
+	}
+	argc -= optind;
+	argv += optind;
+
+	if (argc != 2)
+		usage();
+
+	filename = argv[0];
+	serverurl = argv[1];
+
+	if (background) {
+		error = rump_daemonize_begin();
+		if (error)
+			errx(1, "rump daemonize: %s", strerror(error));
+	}
+
+	error = rump_init();
+	if (error)
+		die("rump init failed", error);
+
+	if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1)
+		atf_tc_fail_errno("mount point create");
+	rump_pub_etfs_register("/diskdev", filename, RUMP_ETFS_BLK);
+	uargs.fspec = __UNCONST("/diskdev");
+	if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, (log) ? MNT_LOG : 0,
+	    &uargs, sizeof(uargs)) == -1)
+		die("mount ffs", errno);
+
+	error = rump_init_server(serverurl);
+	if (error)
+		die("rump server init failed", error);
+	if (background)
+		rump_daemonize_done(RUMP_DAEMONIZE_SUCCESS);
+
+	sem_init(&sigsem, 0, 0);
+	signal(SIGTERM, sigreboot);
+	signal(SIGINT, sigreboot);
+	sem_wait(&sigsem);
+
+	rump_sys_reboot(0, NULL);
+	/*NOTREACHED*/
+	return 0;
+}

Reply via email to