svn commit: samba r19435 - in branches/SAMBA_4_0/source/torture: .

tridge at samba.org tridge at samba.org
Sat Oct 21 06:44:37 GMT 2006


Author: tridge
Date: 2006-10-21 06:44:36 +0000 (Sat, 21 Oct 2006)
New Revision: 19435

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19435

Log:

fixed the subunit code on platforms with small pipe buffers, and use
pipe() on all platforms, not socket pairs (stdin/out are not sockets)

also show the output while its happening, so the tests become useful
again for non-automated usage.

I still really dislike running tests like the TALLOC one as child
processes

Modified:
   branches/SAMBA_4_0/source/torture/subunit.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/subunit.c
===================================================================
--- branches/SAMBA_4_0/source/torture/subunit.c	2006-10-21 06:40:39 UTC (rev 19434)
+++ branches/SAMBA_4_0/source/torture/subunit.c	2006-10-21 06:44:36 UTC (rev 19435)
@@ -94,12 +94,12 @@
 	pid_t pid;
 	int sock_out[2], sock_err[2];
 
-	if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock_out) == -1) {
+	if (pipe(sock_out) == -1) {
 		DEBUG(0, ("socketpair: %s", strerror(errno)));
 		return -1;
 	}
 
-	if (socketpair(AF_UNIX, SOCK_STREAM, 0, sock_err) == -1) {
+	if (pipe(sock_err) == -1) {
 		DEBUG(0, ("socketpair: %s", strerror(errno)));
 		return -1;
 	}
@@ -107,9 +107,6 @@
 	*f_stdout = sock_out[0];
 	*f_stderr = sock_err[0];
 
-	fcntl(sock_out[0], F_SETFL, O_NONBLOCK);
-	fcntl(sock_err[0], F_SETFL, O_NONBLOCK);
-
 	pid = fork();
 
 	if (pid == -1) {
@@ -124,7 +121,7 @@
 		close(sock_out[0]);
 		close(sock_err[0]);
 
-		dup2(sock_out[1], 0);
+		open("/dev/null", O_RDONLY);
 		dup2(sock_out[1], 1);
 		dup2(sock_err[1], 2);
 		execvp(command[0], command);
@@ -195,20 +192,12 @@
 	if (pid == -1)
 		return false;
 
-	if (waitpid(pid, &status, 0) == -1) {
-		torture_result(context, TORTURE_ERROR, "waitpid(%d) failed\n", pid);
-		return false;
-	}
-
-	if (WEXITSTATUS(status) != 0) {
-		torture_result(context, TORTURE_ERROR, "failed with status %d\n", WEXITSTATUS(status));
-		return false;
-	}
-
 	while ((size = read(fd_out, buffer+offset, sizeof(buffer-offset) > 0))) {
 		char *eol;
 		buffer[offset+size] = '\0';
 
+		write(1, buffer+offset, size);
+
 		for (p = buffer; p; p = eol+1) {
 			eol = strchr(p, '\n');
 			if (eol == NULL) 
@@ -263,6 +252,16 @@
 		memcpy(buffer, p, offset);
 	}
 
+	if (waitpid(pid, &status, 0) == -1) {
+		torture_result(context, TORTURE_ERROR, "waitpid(%d) failed\n", pid);
+		return false;
+	}
+
+	if (WEXITSTATUS(status) != 0) {
+		torture_result(context, TORTURE_ERROR, "failed with status %d\n", WEXITSTATUS(status));
+		return false;
+	}
+
 	if (name != NULL) {
 		torture_result(context, TORTURE_ERROR, "Interrupted during %s\n", name);
 		return false;



More information about the samba-cvs mailing list