@@ -25,6 +25,7 @@ $pipes = array();
25
25
26
26
$ process = proc_open (PHP_BINARY .' -n -f ' . $ fl , $ descriptorspec , $ pipes , NULL , NULL , array ("blocking_pipes " => true ));
27
27
28
+ $ moreThanLimit = 0 ;
28
29
for ($ i = 0 ; $ i < 10 ; $ i ++){
29
30
fwrite ($ pipes [0 ], "hello $ i \r\n" );
30
31
fflush ($ pipes [0 ]);
@@ -37,9 +38,7 @@ for($i = 0; $i < 10; $i++){
37
38
38
39
$ dt_ms = ($ t1 - $ t0 )*1000 ;
39
40
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 ++;
43
42
}
44
43
}
45
44
@@ -48,32 +47,28 @@ fclose($pipes[1]);
48
47
49
48
proc_close ($ process );
50
49
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
+
51
56
?>
52
57
===DONE===
53
58
--CLEAN--
54
59
<?php
55
60
$ fl = __DIR__ . DIRECTORY_SEPARATOR . "test69900.php " ;
56
61
@unlink ($ fl );
57
62
?>
58
- --EXPECTF --
63
+ --EXPECT --
59
64
hello0
60
- fgets() took %s
61
65
hello1
62
- fgets() took less than %d ms
63
66
hello2
64
- fgets() took less than %d ms
65
67
hello3
66
- fgets() took less than %d ms
67
68
hello4
68
- fgets() took less than %d ms
69
69
hello5
70
- fgets() took less than %d ms
71
70
hello6
72
- fgets() took less than %d ms
73
71
hello7
74
- fgets() took less than %d ms
75
72
hello8
76
- fgets() took less than %d ms
77
73
hello9
78
- fgets() took less than %d ms
79
74
===DONE===
0 commit comments