Przeglądaj źródła

tests/*server.pl: flush output before executing subprocess

Also avoid shell processes staying around by using exec.
This is necessary to avoid output data being buffering
inside the process chain of Perl, Bash/Shell and our
test server binaries. On non-Windows systems the exec
will also make the subprocess replace the intermediate
shell, but on Windows it will at least bind the processes
together since there is no real fork or exec available.

See: https://cygwin.com/cygwin-ug-net/highlights.html
and: https://docs.microsoft.com/cpp/c-runtime-library/exec-wexec-functions
Ref: https://github.com/curl/curl/pull/7530#issuecomment-900949010

Reviewed-by: Daniel Stenberg
Reviewed-by: Jay Satiro
Closes #7530
Marc Hoersken 2 lat temu
rodzic
commit
5b1c2dd1db

+ 2 - 1
tests/httpserver.pl

@@ -152,4 +152,5 @@ if($verbose) {
     print STDERR "RUN: server/sws".exe_ext('SRV')." $flags\n";
 }
 
-exec("server/sws".exe_ext('SRV')." $flags");
+$| = 1;
+exec("exec server/sws".exe_ext('SRV')." $flags");

+ 2 - 1
tests/rtspserver.pl

@@ -119,4 +119,5 @@ $flags .= "--pidfile \"$pidfile\" ".
     "--logfile \"$logfile\" ";
 $flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
 
-exec("server/rtspd".exe_ext('SRV')." $flags");
+$| = 1;
+exec("exec server/rtspd".exe_ext('SRV')." $flags");

+ 6 - 0
tests/runtests.pl

@@ -496,6 +496,9 @@ sub startnew {
     if(0 == $child) {
         # Here we are the child. Run the given command.
 
+        # Flush output.
+        $| = 1;
+
         # Put an "exec" in front of the command so that the child process
         # keeps this child's process ID.
         exec("exec $cmd") || die "Can't exec() $cmd: $!";
@@ -4108,6 +4111,9 @@ sub singletest {
         close(GDBCMD);
     }
 
+    # Flush output.
+    $| = 1;
+
     # timestamp starting of test command
     $timetoolini{$testnum} = Time::HiRes::time();
 

+ 3 - 0
tests/secureserver.pl

@@ -341,6 +341,9 @@ if($tstunnel_windows) {
         close(OUT);
     }
 
+    # Flush output.
+    $| = 1;
+
     # Put an "exec" in front of the command so that the child process
     # keeps this child's process ID by being tied to the spawned shell.
     exec("exec $cmd") || die "Can't exec() $cmd: $!";

+ 3 - 0
tests/sshserver.pl

@@ -1122,6 +1122,9 @@ if ($sshdid =~ /OpenSSH-Windows/) {
         close(OUT);
     }
 
+    # Flush output.
+    $| = 1;
+
     # Put an "exec" in front of the command so that the child process
     # keeps this child's process ID by being tied to the spawned shell.
     exec("exec $cmd") || die "Can't exec() $cmd: $!";

+ 2 - 1
tests/tftpserver.pl

@@ -120,4 +120,5 @@ $flags .= "--pidfile \"$pidfile\" ".
     "--logfile \"$logfile\" ";
 $flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
 
-exec("server/tftpd".exe_ext('SRV')." $flags");
+$| = 1;
+exec("exec server/tftpd".exe_ext('SRV')." $flags");