提交 561e6073 编写于 作者: D Daniel P. Berrange

Make it easier to debug tests running programs

	* tests/testutils.c: Don't discard stderr when running
	external programs during tests
上级 ad6d5acb
...@@ -156,7 +156,6 @@ void virtTestCaptureProgramExecChild(const char *const argv[], ...@@ -156,7 +156,6 @@ void virtTestCaptureProgramExecChild(const char *const argv[],
int i; int i;
int open_max; int open_max;
int stdinfd = -1; int stdinfd = -1;
int stderrfd = -1;
const char *const env[] = { const char *const env[] = {
"LANG=C", "LANG=C",
#if WITH_DRIVER_MODULES #if WITH_DRIVER_MODULES
...@@ -167,13 +166,10 @@ void virtTestCaptureProgramExecChild(const char *const argv[], ...@@ -167,13 +166,10 @@ void virtTestCaptureProgramExecChild(const char *const argv[],
if ((stdinfd = open("/dev/null", O_RDONLY)) < 0) if ((stdinfd = open("/dev/null", O_RDONLY)) < 0)
goto cleanup; goto cleanup;
if ((stderrfd = open("/dev/null", O_WRONLY)) < 0)
goto cleanup;
open_max = sysconf (_SC_OPEN_MAX); open_max = sysconf (_SC_OPEN_MAX);
for (i = 0; i < open_max; i++) { for (i = 0; i < open_max; i++) {
if (i != stdinfd && if (i != stdinfd &&
i != stderrfd &&
i != pipefd) i != pipefd)
close(i); close(i);
} }
...@@ -182,7 +178,7 @@ void virtTestCaptureProgramExecChild(const char *const argv[], ...@@ -182,7 +178,7 @@ void virtTestCaptureProgramExecChild(const char *const argv[],
goto cleanup; goto cleanup;
if (dup2(pipefd, STDOUT_FILENO) != STDOUT_FILENO) if (dup2(pipefd, STDOUT_FILENO) != STDOUT_FILENO)
goto cleanup; goto cleanup;
if (dup2(stderrfd, STDERR_FILENO) != STDERR_FILENO) if (dup2(pipefd, STDERR_FILENO) != STDERR_FILENO)
goto cleanup; goto cleanup;
/* SUS is crazy here, hence the cast */ /* SUS is crazy here, hence the cast */
...@@ -191,8 +187,6 @@ void virtTestCaptureProgramExecChild(const char *const argv[], ...@@ -191,8 +187,6 @@ void virtTestCaptureProgramExecChild(const char *const argv[],
cleanup: cleanup:
if (stdinfd != -1) if (stdinfd != -1)
close(stdinfd); close(stdinfd);
if (stderrfd != -1)
close(stderrfd);
} }
int virtTestCaptureProgramOutput(const char *const argv[], int virtTestCaptureProgramOutput(const char *const argv[],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册