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())
));
}
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));
}
}
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);
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;
}
$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) {
$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);
echo $e,"\n";
}
}
-
+
proc_terminate($proc);
-
+
fpassthru($stderr);
fpassthru($stdout);
}