From d20fc5a1927c98db7d4e96c17b9988569822592a Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 11 Jul 2019 12:32:57 +0200 Subject: [PATCH] Make proc_open_bug64438.phpt more robust The test currently assumes that we'll first read the data of stdout and stderr and then see eof on stdout and stderr. However we could also read stdout, see eof on stdout, read stderr and see eof on stderr, depending on timing. Avoid output ordering issues by collecting events into a per-pipe array, so interleaving is not visible. --- .../tests/streams/proc_open_bug64438.phpt | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/ext/standard/tests/streams/proc_open_bug64438.phpt b/ext/standard/tests/streams/proc_open_bug64438.phpt index 454d7748c4..2880865e1d 100644 --- a/ext/standard/tests/streams/proc_open_bug64438.phpt +++ b/ext/standard/tests/streams/proc_open_bug64438.phpt @@ -25,6 +25,7 @@ $stdinOffset = 0; unset($pipes[0]); +$pipeEvents = []; while ($pipes || $writePipes) { $r = $pipes; $w = $writePipes; @@ -51,19 +52,35 @@ while ($pipes || $writePipes) { foreach ($r as $pipe) { $type = array_search($pipe, $pipes); $data = fread($pipe, 8192); - var_dump($data); if (false === $data || feof($pipe)) { + $pipeEvents[(int)$pipe][] = "Closing pipe"; fclose($pipe); unset($pipes[$type]); + } else { + $pipeEvents[(int)$pipe][] = "Read " . strlen($data) . " bytes"; } } } +var_dump($pipeEvents); + ?> ===DONE=== --EXPECTF-- -string(4097) "%s" -string(4097) "%s" -string(0) "" -string(0) "" +array(2) { + [%d]=> + array(2) { + [0]=> + string(15) "Read 4097 bytes" + [1]=> + string(12) "Closing pipe" + } + [%d]=> + array(2) { + [0]=> + string(15) "Read 4097 bytes" + [1]=> + string(12) "Closing pipe" + } +} ===DONE=== -- 2.50.1