Commit f93f92db377 for php
commit f93f92db37772fb5daa9adf33f99275d5e6cd525
Author: Michael Orlitzky <michael@orlitzky.com>
Date: Mon Jul 10 21:29:57 2023 -0400
ext/standard/tests: pass TEST_PHP_EXTRA_ARGS to some proc_open() tests
Several of our proc_open() tests fail to pass TEST_PHP_EXTRA_ARGS to
the PHP binary they execute. This can lead to spurious failures when,
for example, the system's INI file is incompatible with the just-built
CLI php:
---- ACTUAL OUTPUT
array(1) {
[2]=>
resource(4) of type (stream)
}
string(123) "Failed loading /usr/lib64/php8.2/lib64/opcache.so:
/usr/lib64/php8.2/lib64/opcache.so: undefined symbol: _emalloc_32
Error"
Naturally we would like to pass TEST_PHP_EXTRA_ARGS to these
invocations, after which "run-tests.php -n" would avoid loading the
incompatible INI file. However, in this case, TEST_PHP_EXTRA_ARGS is a
free-form environment variable, and proc_open() is being fed an array
of arguments. It would be difficult to parse TEST_PHP_EXTRA_ARGS into
an array, so we first convert the command-line array to a string,
and then afterwards simply append the extra args.
diff --git a/ext/standard/tests/general_functions/proc_open_null.phpt b/ext/standard/tests/general_functions/proc_open_null.phpt
index 097d4d2892e..f5ea603f04b 100644
--- a/ext/standard/tests/general_functions/proc_open_null.phpt
+++ b/ext/standard/tests/general_functions/proc_open_null.phpt
@@ -4,7 +4,8 @@
<?php
$php = getenv('TEST_PHP_EXECUTABLE');
-$cmd = [$php, '-r', 'echo "Test"; fprintf(STDERR, "Error");'];
+$args = getenv('TEST_PHP_EXTRA_ARGS');
+$cmd = "$php $args -r 'echo \"Test\"; fprintf(STDERR, \"Error\");'";
$proc = proc_open($cmd, [1 => ['null'], 2 => ['pipe', 'w']], $pipes);
var_dump($pipes);
diff --git a/ext/standard/tests/general_functions/proc_open_redirect.phpt b/ext/standard/tests/general_functions/proc_open_redirect.phpt
index 76940b715d8..c8d29e89477 100644
--- a/ext/standard/tests/general_functions/proc_open_redirect.phpt
+++ b/ext/standard/tests/general_functions/proc_open_redirect.phpt
@@ -4,26 +4,29 @@
<?php
$php = getenv('TEST_PHP_EXECUTABLE');
+$args = getenv('TEST_PHP_EXTRA_ARGS');
+$cmd = "$php $args";
+
try {
- proc_open([$php], [['redirect']], $pipes);
+ proc_open($cmd, [['redirect']], $pipes);
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
}
try {
- proc_open([$php], [['redirect', 'foo']], $pipes);
+ proc_open($cmd, [['redirect', 'foo']], $pipes);
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
}
try {
- proc_open([$php], [['redirect', 42]], $pipes);
+ proc_open($cmd, [['redirect', 42]], $pipes);
} catch (ValueError $exception) {
echo $exception->getMessage() . "\n";
}
echo "\nWith pipe:\n";
-$cmd = [$php, '-r', 'echo "Test\n"; fprintf(STDERR, "Error");'];
+$cmd = "$php $args -r 'echo \"Test\n\"; fprintf(STDERR, \"Error\");'";
$proc = proc_open($cmd, [1 => ['pipe', 'w'], 2 => ['redirect', 1]], $pipes);
var_dump($pipes);
var_dump(stream_get_contents($pipes[1]));
diff --git a/ext/standard/tests/general_functions/proc_open_sockets1.phpt b/ext/standard/tests/general_functions/proc_open_sockets1.phpt
index ce5cca9491e..19608fb606e 100644
--- a/ext/standard/tests/general_functions/proc_open_sockets1.phpt
+++ b/ext/standard/tests/general_functions/proc_open_sockets1.phpt
@@ -7,10 +7,9 @@
--FILE--
<?php
-$cmd = [
- getenv("TEST_PHP_EXECUTABLE"),
- __DIR__ . '/proc_open_sockets1.inc'
-];
+$php = getenv("TEST_PHP_EXECUTABLE");
+$args = getenv("TEST_PHP_EXTRA_ARGS");
+$cmd = "$php $args " . __DIR__ . '/proc_open_sockets1.inc';
$spec = [
['null'],
diff --git a/ext/standard/tests/general_functions/proc_open_sockets2.phpt b/ext/standard/tests/general_functions/proc_open_sockets2.phpt
index 2fd705e9016..06b2c1aa6a4 100644
--- a/ext/standard/tests/general_functions/proc_open_sockets2.phpt
+++ b/ext/standard/tests/general_functions/proc_open_sockets2.phpt
@@ -34,10 +34,9 @@ function write_pipe($pipe, $data)
}
}
-$cmd = [
- getenv("TEST_PHP_EXECUTABLE"),
- __DIR__ . '/proc_open_sockets2.inc'
-];
+$php = getenv("TEST_PHP_EXECUTABLE");
+$args = getenv("TEST_PHP_EXTRA_ARGS");
+$cmd = "$php $args " . __DIR__ . '/proc_open_sockets2.inc';
$spec = [
['socket'],
diff --git a/ext/standard/tests/general_functions/proc_open_sockets3.phpt b/ext/standard/tests/general_functions/proc_open_sockets3.phpt
index 39569595d3a..09eb3ebac2a 100644
--- a/ext/standard/tests/general_functions/proc_open_sockets3.phpt
+++ b/ext/standard/tests/general_functions/proc_open_sockets3.phpt
@@ -25,10 +25,9 @@ function read_pipe($pipe): string
return $chunk;
}
-$cmd = [
- getenv("TEST_PHP_EXECUTABLE"),
- __DIR__ . '/proc_open_sockets2.inc'
-];
+$php = getenv("TEST_PHP_EXECUTABLE");
+$args = getenv("TEST_PHP_EXTRA_ARGS");
+$cmd = "$php $args " . __DIR__ . '/proc_open_sockets2.inc';
$spec = [
['pipe', 'r'],