Skip to content

Commit d5c55f8

Browse files
committed
Try to make proc_open_bug69900.phpt more robust
1 parent b0737fa commit d5c55f8

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

ext/standard/tests/streams/proc_open_bug69900.phpt

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ $pipes = array();
2525

2626
$process = proc_open(PHP_BINARY.' -n -f ' . $fl, $descriptorspec, $pipes, NULL, NULL, array("blocking_pipes" => true));
2727

28+
$moreThanLimit = 0;
2829
for($i = 0; $i < 10; $i++){
2930
fwrite($pipes[0], "hello$i\r\n");
3031
fflush($pipes[0]);
@@ -37,9 +38,7 @@ for($i = 0; $i < 10; $i++){
3738

3839
$dt_ms = ($t1 - $t0)*1000;
3940
if ($dt_ms > $max_ms) {
40-
echo "fgets() took more than $max_ms ms ($dt_ms ms)\n";
41-
} else {
42-
echo "fgets() took less than $max_ms ms\n";
41+
$moreThanLimit++;
4342
}
4443
}
4544

@@ -48,32 +47,28 @@ fclose($pipes[1]);
4847

4948
proc_close($process);
5049

50+
/* It is expected that the first call takes more than the limit.
51+
* Allow one more to account for a possible process switch. */
52+
if ($moreThanLimit > 2) {
53+
echo "fgets() took more than $max_ms ms $moreThanLimit times\n";
54+
}
55+
5156
?>
5257
===DONE===
5358
--CLEAN--
5459
<?php
5560
$fl = __DIR__ . DIRECTORY_SEPARATOR . "test69900.php";
5661
@unlink($fl);
5762
?>
58-
--EXPECTF--
63+
--EXPECT--
5964
hello0
60-
fgets() took %s
6165
hello1
62-
fgets() took less than %d ms
6366
hello2
64-
fgets() took less than %d ms
6567
hello3
66-
fgets() took less than %d ms
6768
hello4
68-
fgets() took less than %d ms
6969
hello5
70-
fgets() took less than %d ms
7170
hello6
72-
fgets() took less than %d ms
7371
hello7
74-
fgets() took less than %d ms
7572
hello8
76-
fgets() took less than %d ms
7773
hello9
78-
fgets() took less than %d ms
7974
===DONE===

0 commit comments

Comments
 (0)