diff --git a/tests/lib/librumpclient/h_exec.c b/tests/lib/librumpclient/h_exec.c index 8d4ffbd12acd..cf2526ced636 100644 --- a/tests/lib/librumpclient/h_exec.c +++ b/tests/lib/librumpclient/h_exec.c @@ -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 @@ main(int argc, char *argv[]) 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 @@ main(int argc, char *argv[]) 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 @@ main(int argc, char *argv[]) } } - 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; diff --git a/tests/lib/librumpclient/t_exec.sh b/tests/lib/librumpclient/t_exec.sh index ae9c1bb85d2d..d95ce4f74909 100644 --- a/tests/lib/librumpclient/t_exec.sh +++ b/tests/lib/librumpclient/t_exec.sh @@ -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 @@ cloexec_cleanup() 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 }