From: gm dot outside+php at gmail dot com Operating system: Linux PHP version: 5.6.1 Package: Testing related Bug Type: Bug Bug description:OpenSSL tests spawn PHP processes without preserving the test environment
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 === -- Edit bug report at https://bugs.php.net/bug.php?id=68230&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68230&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68230&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68230&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=68230&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=68230&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=68230&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=68230&r=needscript Try newer version: https://bugs.php.net/fix.php?id=68230&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=68230&r=support Expected behavior: https://bugs.php.net/fix.php?id=68230&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=68230&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=68230&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=68230&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68230&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=68230&r=dst IIS Stability: https://bugs.php.net/fix.php?id=68230&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=68230&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=68230&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=68230&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=68230&r=mysqlcfg -- PHP Quality Assurance Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php