summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2006-10-21 06:44:36 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:21:31 -0500
commitacadb12c26165825d357499e946875fc33f62344 (patch)
tree1be5dbf69935d5199b12d2d7add8cf77f2ba8680 /source4/torture
parent5ce18f91e0a2776299e5ebc411445c512887d74f (diff)
downloadsamba-acadb12c26165825d357499e946875fc33f62344.tar.gz
samba-acadb12c26165825d357499e946875fc33f62344.tar.bz2
samba-acadb12c26165825d357499e946875fc33f62344.zip
r19435: 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 (This used to be commit b621999c59fc56a32ff574523204355c5e0382c0)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/subunit.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/source4/torture/subunit.c b/source4/torture/subunit.c
index b7d2ad405c..e417b45306 100644
--- a/source4/torture/subunit.c
+++ b/source4/torture/subunit.c
@@ -94,12 +94,12 @@ static pid_t piped_child(char* const command[], int *f_stdout, int *f_stderr)
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 @@ static pid_t piped_child(char* const command[], int *f_stdout, int *f_stderr)
*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 @@ static pid_t piped_child(char* const command[], int *f_stdout, int *f_stderr)
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 @@ bool torture_subunit_run_suite(struct torture_context *context,
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 @@ bool torture_subunit_run_suite(struct torture_context *context,
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;