From d0fcc741100840a9d27bed8ace1ad6224a4e34a9 Mon Sep 17 00:00:00 2001 From: Mitch Hagstrand Date: Wed, 28 Dec 2016 19:29:36 -0800 Subject: [PATCH 1/3] Make Opcache tests using the cli server more reliable Same fix already applied to ext/curl/tests/server.inc and sapi/cli/tests/php_cli_server.inc 1. Increases the amount of time for the PHP built-in server to accept a connection 2. Outputs an error if the PHP built-in server fails --- ext/opcache/tests/php_cli_server.inc | 43 +++++++++++++++++++--------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/ext/opcache/tests/php_cli_server.inc b/ext/opcache/tests/php_cli_server.inc index 0878bfafc0d..ca6854f5536 100644 --- a/ext/opcache/tests/php_cli_server.inc +++ b/ext/opcache/tests/php_cli_server.inc @@ -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 + ); + } ?> From 78675ebd9adbc050718ed5aeea6149e097334008 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 29 Dec 2016 20:59:28 +0100 Subject: [PATCH 2/3] Fix flaky openssl_pkey_new test Public key size may vary by one bit... switch to using %d for key sizes. --- ext/openssl/tests/openssl_pkey_new_basic.phpt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ext/openssl/tests/openssl_pkey_new_basic.phpt b/ext/openssl/tests/openssl_pkey_new_basic.phpt index eee2eb0a0e8..b73b1f580cf 100644 --- a/ext/openssl/tests/openssl_pkey_new_basic.phpt +++ b/ext/openssl/tests/openssl_pkey_new_basic.phpt @@ -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) From 432660f73f929b560d5f9c3d5466e3a2aee42851 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 29 Dec 2016 21:39:40 +0100 Subject: [PATCH 3/3] Another try at making concat_003 more reliable Use array_fill() for the array population loop -- this isn't the part that is being tested and on PHP 7.0 w/o opcache this duplicates the inner array a lot. --- Zend/tests/concat_003.phpt | 40 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/Zend/tests/concat_003.phpt b/Zend/tests/concat_003.phpt index 53d8d2f9a4b..13c6fdc087b 100644 --- a/Zend/tests/concat_003.phpt +++ b/Zend/tests/concat_003.phpt @@ -2,37 +2,24 @@ Concatenating many small strings should not slowdown allocations --SKIPIF-- ---INI-- -memory_limit=256m --FILE-- +++DONE+++ --EXPECT-- bool(true) -bool(true) +++DONE+++