Edit report at https://bugs.php.net/bug.php?id=68230&edit=1
ID: 68230
Comment by: gm dot outside+php at gmail dot com
Reported by: gm dot outside+php at gmail dot com
Summary: OpenSSL tests spawn PHP processes without preserving
the test environment
Status: Open
Type: Bug
Package: Testing related
Operating System: Linux
PHP Version: 5.6.1
Block user comment: N
Private report: N
New Comment:
I've just added a patch that partially fixes the test suite. My patch extracts
the name of the configuration file and/or additional configuration files
provided to testsuite's PHP binary and executes the spawned PHP binary with the
same set of files. It also extracts the extension_dir and supplies it to the
spawned process.
NOTE: This patch is just to fix our build environment so we can build PHP.
This patch does NOT address the real issue of picking up the system-wide
configuration files and it misses any custom configuration supplied to the test
suite.
To properly solve the issue a new mechanism needs to be invented to ensure that
the tests which require spawned children get the proper environment inherited
from the primary test suite process.
Previous Comments:
------------------------------------------------------------------------
[2014-10-15 07:38:04] gm dot outside+php at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=68230&edit=1
--
PHP Quality Assurance Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php