]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
tests: tests stderr redirected to the output
authorJan Hák <jan.hak@nic.cz>
Wed, 26 Apr 2023 11:16:48 +0000 (13:16 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Wed, 26 Apr 2023 13:14:56 +0000 (15:14 +0200)
tests/tap/runtests.c

index 31ac943998e6fe1ee5bace1cbceba590e84cd41e..bd9d106bba5e4a9b4f5df3c25aed050f84c6a43e 100644 (file)
@@ -384,14 +384,14 @@ skip_whitespace(const char *p)
 }
 
 /*
- * Start a program, connecting its stdout to a pipe on our end and its stderr
- * to /dev/null, and storing the file descriptor to read from in the two
- * argument.  Returns the PID of the new process.  Errors are fatal.
+ * Start a program, connecting its output (stdout and stderr) to a pipe on our
+ * end, and storing the file descriptor to read from in the second argument.
+ * Returns the PID of the new process. Errors are fatal.
  */
 static pid_t
 test_start(const char *path, int *fd)
 {
-    int fds[2], errfd;
+    int fds[2];
     pid_t child;
 
     if (pipe(fds) == -1) {
@@ -406,13 +406,10 @@ test_start(const char *path, int *fd)
         sysdie("can't fork");
     } else if (child == 0) {
         /* In child.  Set up our stdout and stderr. */
-        errfd = open("/dev/null", O_WRONLY);
-        if (errfd < 0)
-            _exit(CHILDERR_STDERR);
-        if (dup2(errfd, 2) == -1)
-            _exit(CHILDERR_DUP);
         close(fds[0]);
-        if (dup2(fds[1], 1) == -1)
+        if (dup2(fds[1], STDOUT_FILENO) == -1)
+            _exit(CHILDERR_DUP);
+        if (dup2(fds[1], STDERR_FILENO) == -1)
             _exit(CHILDERR_DUP);
 
         /* Now, exec our process. */