Module Name:    src
Committed By:   pooka
Date:           Wed Feb 16 15:34:18 UTC 2011

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

Log Message:
Don't use hijack here since exec is now easy in pure rump clients.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/librumpclient/h_exec.c
cvs rdiff -u -r1.2 -r1.3 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.3 src/tests/lib/librumpclient/h_exec.c:1.4
--- src/tests/lib/librumpclient/h_exec.c:1.3	Tue Feb 15 15:57:33 2011
+++ src/tests/lib/librumpclient/h_exec.c	Wed Feb 16 15:34:18 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_exec.c,v 1.3 2011/02/15 15:57:33 pooka Exp $	*/
+/*	$NetBSD: h_exec.c,v 1.4 2011/02/16 15:34:18 pooka Exp $	*/
 
 /*
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -40,10 +40,8 @@
 #include <string.h>
 #include <unistd.h>
 
-/*
- * Uses rumphijack because it's convenient with exec.  XXX: fixme to
- * have sensible exec support in rumpclient.
- */
+#include <rump/rumpclient.h>
+#include <rump/rump_syscalls.h>
 
 int
 main(int argc, char *argv[])
@@ -52,6 +50,11 @@
 	socklen_t slen;
 	int s1, s2;
 	char buf[12];
+	char *eargv[4];
+	extern char **environ;
+
+	if (rumpclient_init() == -1)
+		err(1, "init");
 
 	if (argc > 1) {
 		if (strcmp(argv[1], "_didexec") == 0) {
@@ -59,14 +62,14 @@
 			s2 = atoi(argv[2]);
 			slen = sizeof(sin);
 			/* see below */
-			accept(s2, (struct sockaddr *)&sin, &slen);
+			rump_sys_accept(s2, (struct sockaddr *)&sin, &slen);
 		}
 	}
 
 	/* open and listenize two TCP4 suckets */
-	if ((s1 = socket(PF_INET, SOCK_STREAM, 0)) == -1)
+	if ((s1 = rump_sys_socket(PF_INET, SOCK_STREAM, 0)) == -1)
 		err(1, "socket 1");
-	if ((s2 = socket(PF_INET, SOCK_STREAM, 0)) == -1)
+	if ((s2 = rump_sys_socket(PF_INET, SOCK_STREAM, 0)) == -1)
 		err(1, "socket 2");
 
 	memset(&sin, 0, sizeof(sin));
@@ -74,15 +77,15 @@
 	sin.sin_family = AF_INET;
 	sin.sin_port = htons(1234);
 
-	if (bind(s1, (struct sockaddr *)&sin, sizeof(sin)) == -1)
+	if (rump_sys_bind(s1, (struct sockaddr *)&sin, sizeof(sin)) == -1)
 		err(1, "bind1");
 	sin.sin_port = htons(2345);
-	if (bind(s2, (struct sockaddr *)&sin, sizeof(sin)) == -1)
+	if (rump_sys_bind(s2, (struct sockaddr *)&sin, sizeof(sin)) == -1)
 		err(1, "bind2");
 
-	if (listen(s1, 1) == -1)
+	if (rump_sys_listen(s1, 1) == -1)
 		err(1, "listen1");
-	if (listen(s2, 1) == -1)
+	if (rump_sys_listen(s2, 1) == -1)
 		err(1, "listen2");
 
 	if (argc == 1) {
@@ -92,17 +95,21 @@
 		 * "pause()", but conveniently gets rid of this helper
 		 * since we were called with RUMPCLIENT_RETRYCONN_DIE set
 		 */
-		accept(s2, (struct sockaddr *)&sin, &slen);
+		rump_sys_accept(s2, (struct sockaddr *)&sin, &slen);
 	}
 
 	if (argc == 3 && strcmp(argv[2], "cloexec1") == 0) {
-		if (fcntl(s1, F_SETFD, FD_CLOEXEC) == -1) {
+		if (rump_sys_fcntl(s1, F_SETFD, FD_CLOEXEC) == -1) {
 			err(1, "cloexec failed");
 		}
 	}
 
 	/* omstart! */
 	sprintf(buf, "%d", s2);
-	if (execl(argv[1], "h_ution", "_didexec", buf, NULL) == -1)
+	eargv[0] = __UNCONST("h_ution");
+	eargv[1] = __UNCONST("_didexec");
+	eargv[2] = buf;
+	eargv[3] = NULL;
+	if (rumpclient_exec(argv[1], __UNCONST(eargv), environ) == -1)
 		err(1, "exec");
 }

Index: src/tests/lib/librumpclient/t_exec.sh
diff -u src/tests/lib/librumpclient/t_exec.sh:1.2 src/tests/lib/librumpclient/t_exec.sh:1.3
--- src/tests/lib/librumpclient/t_exec.sh:1.2	Tue Feb 15 15:54:56 2011
+++ src/tests/lib/librumpclient/t_exec.sh	Wed Feb 16 15:34:18 2011
@@ -1,4 +1,4 @@
-#       $NetBSD: t_exec.sh,v 1.2 2011/02/15 15:54:56 pooka Exp $
+#       $NetBSD: t_exec.sh,v 1.3 2011/02/16 15:34:18 pooka Exp $
 #
 # Copyright (c) 2011 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -39,8 +39,7 @@
 {
 
 	atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER}
-	atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
-	    $(atf_get_srcdir)/h_exec
+	atf_check -s exit:0 env $(atf_get_srcdir)/h_exec
 	atf_check -s exit:0 -o save:sstat.out rump.sockstat
 	atf_check -s exit:0 -o match:'^root.*h_exec.*tcp.*\*\.1234' \
 	    sed -n 2p sstat.out
@@ -63,8 +62,7 @@
 {
 
 	atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER}
-	atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
-	    $(atf_get_srcdir)/h_exec $(atf_get_srcdir)/h_ution
+	atf_check -s exit:0 $(atf_get_srcdir)/h_exec $(atf_get_srcdir)/h_ution
 	atf_check -s exit:0 -o save:sstat.out rump.sockstat
 	atf_check -s exit:0 -o match:'^root.*h_ution.*tcp.*\*\.1234' \
 	    sed -n 2p sstat.out
@@ -87,7 +85,7 @@
 {
 
 	atf_check -s exit:0 ${rumpsrv} ${RUMP_SERVER}
-	atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \
+	atf_check -s exit:0  \
 	    $(atf_get_srcdir)/h_exec $(atf_get_srcdir)/h_ution cloexec1
 	atf_check -s exit:0 -o save:sstat.out rump.sockstat
 	atf_check -s exit:0 -o inline:'2\n' sed -n '$=' sstat.out

Reply via email to