Skip to content

Commit ca6c542

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Try to make proc_open_bug69900.phpt more robust
2 parents 2bc0a6e + d5c55f8 commit ca6c542

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

ext/standard/tests/streams/proc_open_bug69900.phpt

Lines changed: 10 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,30 +47,27 @@ 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
--CLEAN--
5358
<?php
5459
$fl = __DIR__ . DIRECTORY_SEPARATOR . "test69900.php";
5560
@unlink($fl);
5661
?>
57-
--EXPECTF--
62+
--EXPECT--
5863
hello0
59-
fgets() took %s
6064
hello1
61-
fgets() took less than %d ms
6265
hello2
63-
fgets() took less than %d ms
6466
hello3
65-
fgets() took less than %d ms
6667
hello4
67-
fgets() took less than %d ms
6868
hello5
69-
fgets() took less than %d ms
7069
hello6
71-
fgets() took less than %d ms
7270
hello7
73-
fgets() took less than %d ms
7471
hello8
75-
fgets() took less than %d ms
7672
hello9
77-
fgets() took less than %d ms
73+
===DONE===

0 commit comments

Comments
 (0)