]> granicus.if.org Git - php/commitdiff
If a test does not have any data after 60 seconds of waiting, assume that
authorWez Furlong <wez@php.net>
Sat, 15 Feb 2003 18:09:52 +0000 (18:09 +0000)
committerWez Furlong <wez@php.net>
Sat, 15 Feb 2003 18:09:52 +0000 (18:09 +0000)
it died a horrible death and kill it.
This is useful on windows when a message box is popped-up during an automated
test-run.

run-tests.php

index 646ab253c3a0b072e55ee4b69f1742f5dfa45fce..cb68f326538f50e6b9c196be77edebdab25149cd 100755 (executable)
@@ -516,6 +516,40 @@ function error_report($testname,$logname,$tested)
        }
 }
 
+function system_with_timeout($commandline)
+{
+       $data = "";
+       
+       $proc = proc_open($commandline, array(1 => array('pipe', 'w')), $pipes);
+
+       if (!$proc)
+               return false;
+
+       while (true) {
+               /* hide errors from interrupted syscalls */
+               $r = $pipes;
+               $w = null;
+               $e = null;
+               $n = stream_select($r, $w, $e, 60);
+
+               if ($n == 0) {
+                       /* timed out */
+                       $data .= "\n ** ERROR: process timed out **\n";
+                       proc_terminate($proc);
+                       return $data;
+               } else if ($n) {
+                       $line = fgets($pipes[1]);
+                       if ($line === false) {
+                               /* EOF */
+                               break;
+                       }
+                       $data .= $line;
+               }
+       }
+       $code = proc_close($proc);
+       return $data;
+}
+
 //
 //  Run an individual test case.
 //
@@ -667,7 +701,8 @@ SCRIPT_FILENAME = " . getenv("SCRIPT_FILENAME") . "
 COMMAND $cmd
 ";
 
-       $out = `$cmd`;
+//     $out = `$cmd`;
+       $out = system_with_timeout($cmd);
 
        @unlink($tmp_post);