1
0
mirror of https://github.com/php/php-src.git synced 2026-04-04 22:52:40 +02:00

Merge branch 'PHP-8.1' into PHP-8.2

* PHP-8.1:
  Fix test bug60120.phpt
This commit is contained in:
Ilija Tovilo
2023-04-13 12:57:10 +02:00

View File

@@ -6,6 +6,7 @@ $php = getenv('TEST_PHP_EXECUTABLE');
if (!$php) {
die("skip No php executable defined\n");
}
if (PHP_OS_FAMILY === 'Windows') die('skip not for Windows');
?>
--FILE--
<?php
@@ -16,7 +17,7 @@ $php = getenv('TEST_PHP_EXECUTABLE');
if (!$php) {
die("No php executable defined\n");
}
$cmd = 'php -r "fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);"';
$cmd = $php . ' -r "\$in = file_get_contents(\'php://stdin\'); fwrite(STDOUT, \$in); fwrite(STDERR, \$in);"';
$descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
$stdin = str_repeat('*', 2049 );
@@ -32,6 +33,7 @@ $stdinOffset = 0;
unset($pipes[0]);
$procOutput = [];
while ($pipes || $writePipes) {
$r = $pipes;
$w = $writePipes;
@@ -48,6 +50,8 @@ while ($pipes || $writePipes) {
$written = fwrite($writePipes[0], substr($stdin, $stdinOffset), 8192);
if (false !== $written) {
$stdinOffset += $written;
} else {
die('Failed to write to pipe');
}
if ($stdinOffset >= $stdinLen) {
fclose($writePipes[0]);
@@ -58,12 +62,21 @@ while ($pipes || $writePipes) {
foreach ($r as $pipe) {
$type = array_search($pipe, $pipes);
$data = fread($pipe, 8192);
if (false === $data || feof($pipe)) {
if (feof($pipe)) {
fclose($pipe);
unset($pipes[$type]);
} elseif (false === $data) {
die('Failed to read from pipe');
} else {
$procOutput[$type] = ($procOutput[$type] ?? '') . $data;
}
}
}
foreach ($procOutput as $output) {
if ($output !== $stdin) {
die('Output does not match input: ' . $output);
}
}
echo "OK.";
?>
--EXPECT--