X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2Fhelper%2Fserver.inc;h=b5bc3b7f4564d014b8636870c2de1bd51bf92bba;hb=HEAD;hp=ea83f70679b073f1dc75dbbf30261c14f6567ef7;hpb=2ac8caf0e31b5dfd386c0a0b811cd918620c0a17;p=m6w6%2Fext-http diff --git a/tests/helper/server.inc b/tests/helper/server.inc index ea83f70..b5bc3b7 100644 --- a/tests/helper/server.inc +++ b/tests/helper/server.inc @@ -7,9 +7,9 @@ function logger() { if (!ini_get("date.timezone")) { date_default_timezone_set(@date_default_timezone_get()); } - error_log(sprintf("%s(%s): %s", - basename(getenv("SCRIPT_FILENAME"), ".php"), - basename(current(get_included_files()), ".inc"), + error_log(sprintf("%s(%s): %s", + basename(getenv("SCRIPT_FILENAME"), ".php"), + basename(current(get_included_files()), ".inc"), call_user_func_array("sprintf", func_get_args()) )); } @@ -24,7 +24,7 @@ if ($php) { define("PHP_BIN", PHP_BINDIR.DIRECTORY_SEPARATOR."php"); } -foreach (array("raphf", "propro", "http") as $ext) { +foreach (array("raphf", "http") as $ext) { if (!extension_loaded($ext)) { dl(ext_lib_name($ext)); } @@ -72,11 +72,11 @@ function ext_lib_name($ext) { } function serve($cb) { - /* stream_socket_server() automatically sets SO_REUSEADDR, + /* 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) { + foreach (range(40000+$offset, 50000+$offset) as $port) { logger("serve: Trying port %d", $port); if (($server = @stream_socket_server("tcp://localhost:$port"))) { fprintf(STDERR, "%s\n", $port); @@ -124,14 +124,14 @@ function server($handler, $cb) { continue; } if ($argList[$i] === '-d') { - $args[] = '-d' . $args[++$i]; + $args[] = '-d' . $argList[++$i]; continue; } if (substr($argList[$i], 0, 2) === '-d') { $args[] = $argList[$i]; } } - foreach (['raphf', 'propro', 'http'] as $ext) { + foreach (['raphf', 'http'] as $ext) { if (null !== $arg = get_extension_load_arg(PHP_BIN, $args, $ext)) { $args[] = $arg; } @@ -149,28 +149,28 @@ function nghttpd($cb) { $stdin = $pipes[0]; $stdout = $pipes[1]; $stderr = $pipes[2]; - + sleep(1); $status = proc_get_status($proc); logger("nghttpd: %s", new http\Params($status)); if (!$status["running"]) { continue; } - + try { $cb($port, $stdin, $stdout, $stderr); } catch (Exception $e) { echo $e,"\n"; } - + proc_terminate($proc); - + fpassthru($stderr); fpassthru($stdout); return; } } - + } function proc($bin, $args, $cb) { @@ -186,7 +186,7 @@ function proc($bin, $args, $cb) { $port = trim(fgets($stderr)); $R = array($stderr); $W = array(); $E = array(); } while (is_numeric($port) && stream_select($R, $W, $E, 0, 10000)); - + if (is_numeric($port)) { try { $cb($port, $stdin, $stdout, $stderr); @@ -194,9 +194,9 @@ function proc($bin, $args, $cb) { echo $e,"\n"; } } - + proc_terminate($proc); - + fpassthru($stderr); fpassthru($stdout); }