Module Name:    src
Committed By:   pooka
Date:           Wed Feb 16 17:57:44 UTC 2011

Modified Files:
        src/tests/lib/librumpclient: h_exec.c t_exec.sh

Log Message:
test rumpclient_vfork()


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/librumpclient/h_exec.c
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/librumpclient/t_exec.sh

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

Modified files:

Index: src/tests/lib/librumpclient/h_exec.c
diff -u src/tests/lib/librumpclient/h_exec.c:1.5 src/tests/lib/librumpclient/h_exec.c:1.6
--- src/tests/lib/librumpclient/h_exec.c:1.5	Wed Feb 16 16:02:52 2011
+++ src/tests/lib/librumpclient/h_exec.c	Wed Feb 16 17:57:44 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_exec.c,v 1.5 2011/02/16 16:02:52 pooka Exp $	*/
+/*	$NetBSD: h_exec.c,v 1.6 2011/02/16 17:57:44 pooka Exp $	*/
 
 /*
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
 
 	if (argc > 1) {
 		if (strcmp(argv[1], "_didexec") == 0) {
-			daemon(0, 0); /* detach-me-notnot ergo detach */
+			rumpclient_daemon(0, 0); /* detach-me-notnot */
 			s2 = atoi(argv[2]);
 			slen = sizeof(sin);
 			/* see below */
@@ -90,7 +90,7 @@
 		err(1, "listen2");
 
 	if (argc == 1) {
-		daemon(0, 0);
+		rumpclient_daemon(0, 0);
 		slen = sizeof(sin);
 		/*
 		 * "pause()", but conveniently gets rid of this helper
@@ -105,10 +105,24 @@
 		}
 	}
 
-	ename = __UNCONST("h_ution");
+	sprintf(buf, "%d", s2);
+
+	if (argc == 3 && strcmp(argv[2], "vfork_please") == 0) {
+		switch (rumpclient_vfork()) {
+		case 0:
+			ename = __UNCONST("fourchette");
+			break;
+		case -1:
+			err(1, "vfork");
+		default:
+			ename = __UNCONST("h_ution");
+			break;
+		}
+	} else {
+		ename = __UNCONST("h_ution");
+	}
 
 	/* omstart! */
-	sprintf(buf, "%d", s2);
 	eargv[0] = ename;
 	eargv[1] = __UNCONST("_didexec");
 	eargv[2] = buf;

Index: src/tests/lib/librumpclient/t_exec.sh
diff -u src/tests/lib/librumpclient/t_exec.sh:1.4 src/tests/lib/librumpclient/t_exec.sh:1.5
--- src/tests/lib/librumpclient/t_exec.sh:1.4	Wed Feb 16 16:02:52 2011
+++ src/tests/lib/librumpclient/t_exec.sh	Wed Feb 16 17:57:44 2011
@@ -1,4 +1,4 @@
-#       $NetBSD: t_exec.sh,v 1.4 2011/02/16 16:02:52 pooka Exp $
+#       $NetBSD: t_exec.sh,v 1.5 2011/02/16 17:57:44 pooka Exp $
 #
 # Copyright (c) 2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -98,10 +98,40 @@
 	rump.halt
 }
 
+atf_test_case vfork cleanup
+vfork_head()
+{
+        atf_set "descr" "test rumpclient_vfork()"
+}
+
+vfork_body()
+{
+
+	atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER}
+	atf_check -s exit:0  \
+	    $(atf_get_srcdir)/h_exec $(atf_get_srcdir)/h_exec vfork_please
+	atf_check -s exit:0 -o save:sstat.out rump.sockstat
+	atf_check -s exit:0 -o inline:'5\n' sed -n '$=' sstat.out
+	atf_check -s exit:0 -o match:'^root.*h_ution.*tcp.*\*\.1234' \
+	    cat sstat.out
+	atf_check -s exit:0 -o match:'^root.*h_ution.*tcp.*\*\.2345' \
+	    cat sstat.out
+	atf_check -s exit:0 -o match:'^root.*fourchette.*tcp.*\*\.1234' \
+	    cat sstat.out
+	atf_check -s exit:0 -o match:'^root.*fourchette.*tcp.*\*\.2345' \
+	    cat sstat.out
+}
+
+vfork_cleanup()
+{
+	rump.halt
+}
+
 
 atf_init_test_cases()
 {
 	atf_add_test_case noexec
 	atf_add_test_case exec
 	atf_add_test_case cloexec
+	atf_add_test_case vfork
 }

Reply via email to