Skip to content

Fix test bug60120.phpt #11064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/scripts/windows/test_task.bat
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ rem generate php.ini
echo extension_dir=%PHP_BUILD_DIR% > %PHP_BUILD_DIR%\php.ini
echo opcache.file_cache=%PHP_BUILD_DIR%\test_file_cache >> %PHP_BUILD_DIR%\php.ini
if "%OPCACHE%" equ "1" echo zend_extension=php_opcache.dll >> %PHP_BUILD_DIR%\php.ini
rem work-around for some spawned PHP processes requiring OpenSSL
echo extension=php_openssl.dll >> %PHP_BUILD_DIR%\php.ini

rem remove ext dlls for which tests are not supported
for %%i in (imap ldap oci8_12c pdo_firebird pdo_oci snmp) do (
Expand Down
16 changes: 14 additions & 2 deletions ext/standard/tests/file/bug60120.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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 );

Expand All @@ -32,6 +32,7 @@ $stdinOffset = 0;

unset($pipes[0]);

$procOutput = [];
while ($pipes || $writePipes) {
$r = $pipes;
$w = $writePipes;
Expand All @@ -48,6 +49,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]);
Expand All @@ -58,12 +61,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--
Expand Down