Skip to content

Commit 049f286

Browse files
committed
Fix test bug60120.phpt
The process cmd was broken. We're now also checking that the process output is actually what we expect.
1 parent 450fcc4 commit 049f286

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

ext/standard/tests/file/bug60120.phpt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $php = getenv('TEST_PHP_EXECUTABLE');
1616
if (!$php) {
1717
die("No php executable defined\n");
1818
}
19-
$cmd = 'php -r "fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);"';
19+
$cmd = $php . ' -r "\$in = file_get_contents(\'php://stdin\'); fwrite(STDOUT, \$in); fwrite(STDERR, \$in);"';
2020
$descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
2121
$stdin = str_repeat('*', 2049 );
2222

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

3333
unset($pipes[0]);
3434

35+
$procOutput = [];
3536
while ($pipes || $writePipes) {
3637
$r = $pipes;
3738
$w = $writePipes;
@@ -48,6 +49,8 @@ while ($pipes || $writePipes) {
4849
$written = fwrite($writePipes[0], substr($stdin, $stdinOffset), 8192);
4950
if (false !== $written) {
5051
$stdinOffset += $written;
52+
} else {
53+
die('Failed to write to pipe');
5154
}
5255
if ($stdinOffset >= $stdinLen) {
5356
fclose($writePipes[0]);
@@ -58,12 +61,21 @@ while ($pipes || $writePipes) {
5861
foreach ($r as $pipe) {
5962
$type = array_search($pipe, $pipes);
6063
$data = fread($pipe, 8192);
61-
if (false === $data || feof($pipe)) {
64+
if (feof($pipe)) {
6265
fclose($pipe);
6366
unset($pipes[$type]);
67+
} elseif (false === $data) {
68+
die('Failed to read from pipe');
69+
} else {
70+
$procOutput[$type] = ($procOutput[$type] ?? '') . $data;
6471
}
6572
}
6673
}
74+
foreach ($procOutput as $output) {
75+
if ($output !== $stdin) {
76+
die('Output does not match input: ' . $output);
77+
}
78+
}
6779
echo "OK.";
6880
?>
6981
--EXPECT--

0 commit comments

Comments
 (0)