1
0
mirror of https://github.com/php/php-src.git synced 2026-04-12 18:43:37 +02:00

Merge branch 'PHP-7.0' of https://git.php.net/repository/php-src into PHP-7.0

* 'PHP-7.0' of https://git.php.net/repository/php-src:
  Another try at making concat_003 more reliable
  Fix flaky openssl_pkey_new test
  Make Opcache tests using the cli server more reliable
This commit is contained in:
Christoph M. Becker
2016-12-30 13:56:34 +01:00
3 changed files with 49 additions and 48 deletions

View File

@@ -2,37 +2,24 @@
Concatenating many small strings should not slowdown allocations
--SKIPIF--
<?php if (PHP_DEBUG) { die ("skip debug version is slow"); } ?>
--INI--
memory_limit=256m
--FILE--
<?php
/* To note is that memory usage can vary depending on whether opcache is on. The actual
measuring that matters is timing here. */
$time = microtime(TRUE);
/* This might vary on Linux/Windows, so the worst case and also count in slow machines. */
$t0_max = 0.3;
$t1_max = 1.0;
$t_max = 1.0;
$datas = [];
for ($i = 0; $i < 220000; $i++)
{
$datas[] = [
'000.000.000.000',
'000.255.255.255',
'保留地址',
'保留地址',
'保留地址',
'保留地址',
'保留地址',
'保留地址',
];
}
$t0 = microtime(TRUE) - $time;
var_dump($t0 < $t0_max);
$datas = array_fill(0, 220000, [
'000.000.000.000',
'000.255.255.255',
'保留地址',
'保留地址',
'保留地址',
'保留地址',
'保留地址',
'保留地址',
]);
$time = microtime(TRUE);
$texts = '';
@@ -41,12 +28,11 @@ foreach ($datas AS $data)
$texts .= implode("\t", $data) . "\r\n";
}
$t1 = microtime(TRUE) - $time;
var_dump($t1 < $t1_max);
$t = microtime(TRUE) - $time;
var_dump($t < $t_max);
?>
+++DONE+++
--EXPECT--
bool(true)
bool(true)
+++DONE+++

View File

@@ -20,28 +20,43 @@ function php_cli_server_start($ini = "") {
$cmd = "exec {$php_executable} -t {$doc_root} $ini -S " . PHP_CLI_SERVER_ADDRESS . " 2>/dev/null";
$handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root);
}
// note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.'
// it might not be listening yet...need to wait until fsockopen() call returns
$i = 0;
while (($i++ < 30) && !($fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT))) {
usleep(10000);
}
$error = "Unable to connect to servers\n";
for ($i=0; $i < 60; $i++) {
usleep(25000); // 25ms per try
$status = proc_get_status($handle);
$fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT);
// Failure, the server is no longer running
if (!($status && $status['running'])) {
$error = "Server is not running\n";
break;
}
// Success, Connected to servers
if ($fp) {
$error = '';
break;
}
}
if ($fp) {
fclose($fp);
}
if ($fp) {
fclose($fp);
}
if ($error) {
echo $error;
proc_terminate($handle);
exit(1);
}
register_shutdown_function(
function($handle) {
proc_terminate($handle);
},
$handle
);
// don't bother sleeping, server is already up
// server can take a variable amount of time to be up, so just sleeping a guessed amount of time
// does not work. this is why tests sometimes pass and sometimes fail. to get a reliable pass
// sleeping doesn't work.
$handle
);
}
?>

View File

@@ -86,10 +86,10 @@ $details = openssl_pkey_get_details($dh);
$dh_details = $details['dh'];
openssl_pkey_test_cmp($phex, $dh_details['p']);
var_dump($dh_details['g']);
var_dump(strlen($dh_details['pub_key']) > 0);
var_dump(strlen($dh_details['priv_key']) > 0);
var_dump(strlen($dh_details['pub_key']));
var_dump(strlen($dh_details['priv_key']));
?>
--EXPECT--
--EXPECTF--
int(0)
int(0)
int(0)
@@ -98,9 +98,9 @@ int(0)
int(0)
int(0)
int(0)
int(20)
int(128)
int(%d)
int(%d)
int(0)
string(1) "2"
bool(true)
bool(true)
int(%d)
int(%d)