Skip to content

Commit 92669d7

Browse files
committed
Merge branch 'PHP-8.2'
* PHP-8.2: Fix test bug60120.phpt
2 parents 00008a8 + de9ea68 commit 92669d7

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

ext/standard/tests/file/bug60120.phpt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ $php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
66
if (!$php) {
77
die("skip No php executable defined\n");
88
}
9+
if (PHP_OS_FAMILY === 'Windows') die('skip not for Windows');
910
?>
1011
--FILE--
1112
<?php
1213

1314
error_reporting(E_ALL);
1415

1516
$php = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
16-
$cmd = $php . ' -r "fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);"';
17+
$cmd = $php . ' -r "\$in = file_get_contents(\'php://stdin\'); fwrite(STDOUT, \$in); fwrite(STDERR, \$in);"';
1718
$descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
1819
$stdin = str_repeat('*', 2049 );
1920

@@ -29,6 +30,7 @@ $stdinOffset = 0;
2930

3031
unset($pipes[0]);
3132

33+
$procOutput = [];
3234
while ($pipes || $writePipes) {
3335
$r = $pipes;
3436
$w = $writePipes;
@@ -45,6 +47,8 @@ while ($pipes || $writePipes) {
4547
$written = fwrite($writePipes[0], substr($stdin, $stdinOffset), 8192);
4648
if (false !== $written) {
4749
$stdinOffset += $written;
50+
} else {
51+
die('Failed to write to pipe');
4852
}
4953
if ($stdinOffset >= $stdinLen) {
5054
fclose($writePipes[0]);
@@ -55,12 +59,21 @@ while ($pipes || $writePipes) {
5559
foreach ($r as $pipe) {
5660
$type = array_search($pipe, $pipes);
5761
$data = fread($pipe, 8192);
58-
if (false === $data || feof($pipe)) {
62+
if (feof($pipe)) {
5963
fclose($pipe);
6064
unset($pipes[$type]);
65+
} elseif (false === $data) {
66+
die('Failed to read from pipe');
67+
} else {
68+
$procOutput[$type] = ($procOutput[$type] ?? '') . $data;
6169
}
6270
}
6371
}
72+
foreach ($procOutput as $output) {
73+
if ($output !== $stdin) {
74+
die('Output does not match input: ' . $output);
75+
}
76+
}
6477
echo "OK.";
6578
?>
6679
--EXPECT--

0 commit comments

Comments
 (0)