|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchesphp-5.6.1-owlx-tests-openssl.diff (last revision 2014-10-15 08:09 UTC by gm dot outside+php at gmail dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-10-15 08:15 UTC] gm dot outside+php at gmail dot com
[2014-10-17 13:37 UTC] tyrael@php.net
-Assigned To:
+Assigned To: tyrael
[2015-12-06 16:26 UTC] rainer dot jung at kippdata dot de
[2017-10-24 04:33 UTC] kalle@php.net
-Status: Assigned
+Status: Open
-Assigned To: tyrael
+Assigned To:
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 14:00:01 2025 UTC |
Description: ------------ In the test suite for the OpenSSL extension (ext/openssl) some tests require the server/client architecture. Therefore they spawn two processes (a server and a client) to perform the tests. Unfortunately, the way it's currently implemented does not provide reliable testing environment since the spawned instances are not preserving the environment the original test suite was launched in. In the ext/openssl/tests/ServerClientTestCase.inc file there is a function called "spawnWorkerProcess()" and it simply executes the PHP binary followed by the script file name and script's arguments. This picks up the system-wide PHP configuration files and can mess the testing up a lot, especially if the system-wide PHP is much older or configured significantly different than the one we are trying to build and test. For example, this is how the PHP test suite is executed in our package builder: === export REPORT_EXIT_STATUS=1 MALLOC_CHECK_=2 export TEST_PHP_SRCDIR=.. unset TZ LANG LC_ALL sapi/cli/php -n -c ./php-tests.ini -d extension_dir=modules \ ../run-tests.php -p "$PWD/sapi/cli/php" -q --offline \ -n -c "$PWD/php-tests.ini" -d "extension_dir=$PWD/modules" === As you can see, "-n" ensures that we are not picking up any default configuration files, followed by "-c" that specifies explicitly which configuration file to use for the test purposes. Then we define the location of modules. This is done for both the PHP/CLI executing the test suite and as the arguments to the test suite script itself. The latter ensures that when the test suite generates test scripts it produces something like the following: === /php-5.6.1/ext/openssl/tests $ cat bug48182.sh #!/bin/sh /php-5.6.1/build-cgi/sapi/cli/php -n -c '/php-5.6.1/build-cgi/php-tests.ini' -d "output_handler=" -d "open_basedir=" -d "safe_mode=0" -d "disable_functions=" -d "output_buffering=Off" -d "error_reporting=32767" -d "display_errors=1" -d "display_startup_errors=1" -d "log_errors=0" -d "html_errors=0" -d "track_errors=1" -d "report_memleaks=1" -d "report_zend_debug=0" -d "docref_root=" -d "docref_ext=.html" -d "error_prepend_string=" -d "error_append_string=" -d "auto_prepend_file=" -d "auto_append_file=" -d "magic_quotes_runtime=0" -d "ignore_repeated_errors=0" -d "precision=14" -d "memory_limit=128M" -d "opcache.fast_shutdown=0" -d "opcache.file_update_protection=0" -d "extension_dir=/php-5.6.1/build-cgi/modules" -d "session.auto_start=0" -d "zlib.output_compression=Off" -d "mbstring.func_overload=0" -f "/php-5.6.1/ext/openssl/tests/bug48182.php" 2>&1 === Now, all these settings are NOT honoured by the client/server OpenSSL tests since they are spawned via the spawnWorkerProcess() routine which does not prepare the test environment correctly. Test script: --------------- It's enough to disable the openssl.so extension in /etc/php (i.e. in the system-wide configuration), but enable it in the custom configuration file that is provided to the test suite run. Expected result: ---------------- All OpenSSL test pass their checks. Actual result: -------------- Tests are failing with the following output: === /php-5.6.1/ext/openssl/tests $ ./bug48182.sh Running bug48182 Warning: stream_socket_client(): SSL: Connection refused in /php-5.6.1/ext/openssl/tests/ServerClientTestCase.inc(92) : eval()'d code on line 9 Warning: stream_socket_client(): Failed to enable crypto in /php-5.6.1/ext/openssl/tests/ServerClientTestCase.inc(92) : eval()'d code on line 9 Warning: stream_socket_client(): unable to connect to ssl://127.0.0.1:64321 (Unknown error) in /php-5.6.1/ext/openssl/tests/ServerClientTestCase.inc(92) : eval()'d code on line 9 Warning: fwrite() expects parameter 1 to be resource, boolean given in /php-5.6.1/ext/openssl/tests/ServerClientTestCase.inc(92) : eval()'d code on line 13 Warning: fread() expects parameter 1 to be resource, boolean given in /php-5.6.1/ext/openssl/tests/ServerClientTestCase.inc(92) : eval()'d code on line 14 === But the real error can be seen by strace'ing the script: === [...] 28460 write(1, "\nWarning: stream_socket_server(): unable to connect to ssl://127.0.0.1:64321 (Unable to find the socket transport \"ssl\" - did you forget to enable it when you configured PHP?) in /php-5.6.1/ext/openssl/tests/ServerClientTestCase.inc(86) : eval()'d code on line 7\n", 290) = 290 ===