add some error logging
[m6w6/ext-http] / tests / helper / server.inc
index 265a861a4a9129656c24adc529d4f70fd99780f8..1bf5eb8f1978e9005c8ed57e62be48f95ece144e 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 
+ini_set("log_errors", true);
+ini_set("error_log", __DIR__."/server.log");
+
 $php = getenv('TEST_PHP_EXECUTABLE');
 if ($php) {
        define('PHP_BIN', $php);
@@ -11,7 +14,11 @@ if ($php) {
 }
 
 function serve($cb) {
-       foreach (range(8000+PHP_INT_SIZE, 9000) as $port) {
+       /* stream_socket_server() automatically sets SO_REUSEADDR, 
+        * which is, well, bad if the tests are run in parallel
+        */
+       $offset = rand(0,2000);
+       foreach (range(8000+$offset, 9000+$offset) as $port) {
                if (($server = @stream_socket_server("tcp://localhost:$port"))) {
                        fprintf(STDERR, "%s\n", $port);
                        do {
@@ -50,7 +57,8 @@ function server($handler, $cb) {
 
 function nghttpd($cb) {
        $spec = array(array("pipe","r"), array("pipe","w"), array("pipe","w"));
-       foreach (range(8000+PHP_INT_SIZE, 9000) as $port) {
+       $offset = rand(0,2000);
+       foreach (range(8000+$offset, 9000+$offset) as $port) {
                $comm = "exec nghttpd -d html $port http2.key http2.crt";
                if (($proc = proc_open($comm, $spec, $pipes, __DIR__))) {
                        $stdin = $pipes[0];