Skip to content

Commit abaed39

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 4be6435 commit abaed39

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ext/standard/tests/file/bug60120.phpt

Lines changed: 12 additions & 1 deletion
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]);
@@ -61,9 +64,17 @@ while ($pipes || $writePipes) {
6164
if (false === $data || feof($pipe)) {
6265
fclose($pipe);
6366
unset($pipes[$type]);
67+
} else {
68+
$resourceId = get_resource_id($pipe);
69+
$procOutput[$resourceId] = ($procOutput[$resourceId] ?? '') . $data;
6470
}
6571
}
6672
}
73+
foreach ($procOutput as $output) {
74+
if ($output !== $stdin) {
75+
die('Output does not match input');
76+
}
77+
}
6778
echo "OK.";
6879
?>
6980
--EXPECT--

0 commit comments

Comments
 (0)