Skip to content

Commit 97e16eb

Browse files
committed
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
2 parents 88d1a2c + 432660f commit 97e16eb

File tree

3 files changed

+50
-49
lines changed

3 files changed

+50
-49
lines changed

Zend/tests/concat_003.phpt

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,24 @@
22
Concatenating many small strings should not slowdown allocations
33
--SKIPIF--
44
<?php if (PHP_DEBUG) { die ("skip debug version is slow"); } ?>
5-
--INI--
6-
memory_limit=256m
75
--FILE--
86
<?php
97

10-
/* To note is that memory usage can vary depending on whether opcache is on. The actual
11-
measuring that matters is timing here. */
12-
138
$time = microtime(TRUE);
149

1510
/* This might vary on Linux/Windows, so the worst case and also count in slow machines. */
16-
$t0_max = 0.3;
17-
$t1_max = 1.0;
18-
19-
$datas = [];
20-
for ($i = 0; $i < 220000; $i++)
21-
{
22-
$datas[] = [
23-
'000.000.000.000',
24-
'000.255.255.255',
25-
'保留地址',
26-
'保留地址',
27-
'保留地址',
28-
'保留地址',
29-
'保留地址',
30-
'保留地址',
31-
];
32-
}
33-
34-
$t0 = microtime(TRUE) - $time;
35-
var_dump($t0 < $t0_max);
11+
$t_max = 1.0;
12+
13+
$datas = array_fill(0, 220000, [
14+
'000.000.000.000',
15+
'000.255.255.255',
16+
'保留地址',
17+
'保留地址',
18+
'保留地址',
19+
'保留地址',
20+
'保留地址',
21+
'保留地址',
22+
]);
3623

3724
$time = microtime(TRUE);
3825
$texts = '';
@@ -41,12 +28,11 @@ foreach ($datas AS $data)
4128
$texts .= implode("\t", $data) . "\r\n";
4229
}
4330

44-
$t1 = microtime(TRUE) - $time;
45-
var_dump($t1 < $t1_max);
31+
$t = microtime(TRUE) - $time;
32+
var_dump($t < $t_max);
4633

4734
?>
4835
+++DONE+++
4936
--EXPECT--
5037
bool(true)
51-
bool(true)
5238
+++DONE+++

ext/opcache/tests/php_cli_server.inc

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,43 @@ function php_cli_server_start($ini = "") {
2020
$cmd = "exec {$php_executable} -t {$doc_root} $ini -S " . PHP_CLI_SERVER_ADDRESS . " 2>/dev/null";
2121
$handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root);
2222
}
23-
23+
2424
// note: even when server prints 'Listening on localhost:8964...Press Ctrl-C to quit.'
2525
// it might not be listening yet...need to wait until fsockopen() call returns
26-
$i = 0;
27-
while (($i++ < 30) && !($fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT))) {
28-
usleep(10000);
29-
}
26+
$error = "Unable to connect to servers\n";
27+
for ($i=0; $i < 60; $i++) {
28+
usleep(25000); // 25ms per try
29+
$status = proc_get_status($handle);
30+
$fp = @fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT);
31+
// Failure, the server is no longer running
32+
if (!($status && $status['running'])) {
33+
$error = "Server is not running\n";
34+
break;
35+
}
36+
// Success, Connected to servers
37+
if ($fp) {
38+
$error = '';
39+
break;
40+
}
41+
}
3042

31-
if ($fp) {
32-
fclose($fp);
33-
}
43+
if ($fp) {
44+
fclose($fp);
45+
}
46+
47+
if ($error) {
48+
echo $error;
49+
proc_terminate($handle);
50+
exit(1);
51+
}
3452

3553
register_shutdown_function(
3654
function($handle) {
3755
proc_terminate($handle);
3856
},
39-
$handle
40-
);
41-
// don't bother sleeping, server is already up
42-
// server can take a variable amount of time to be up, so just sleeping a guessed amount of time
43-
// does not work. this is why tests sometimes pass and sometimes fail. to get a reliable pass
44-
// sleeping doesn't work.
57+
$handle
58+
);
59+
4560
}
4661
?>
4762

ext/openssl/tests/openssl_pkey_new_basic.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ $details = openssl_pkey_get_details($dh);
8686
$dh_details = $details['dh'];
8787
openssl_pkey_test_cmp($phex, $dh_details['p']);
8888
var_dump($dh_details['g']);
89-
var_dump(strlen($dh_details['pub_key']) > 0);
90-
var_dump(strlen($dh_details['priv_key']) > 0);
89+
var_dump(strlen($dh_details['pub_key']));
90+
var_dump(strlen($dh_details['priv_key']));
9191
?>
92-
--EXPECT--
92+
--EXPECTF--
9393
int(0)
9494
int(0)
9595
int(0)
@@ -98,9 +98,9 @@ int(0)
9898
int(0)
9999
int(0)
100100
int(0)
101-
int(20)
102-
int(128)
101+
int(%d)
102+
int(%d)
103103
int(0)
104104
string(1) "2"
105-
bool(true)
106-
bool(true)
105+
int(%d)
106+
int(%d)

0 commit comments

Comments
 (0)