@@ -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,30 +47,27 @@ 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
--CLEAN--
53
58
<?php
54
59
$ fl = __DIR__ . DIRECTORY_SEPARATOR . "test69900.php " ;
55
60
@unlink ($ fl );
56
61
?>
57
- --EXPECTF --
62
+ --EXPECT --
58
63
hello0
59
- fgets() took %s
60
64
hello1
61
- fgets() took less than %d ms
62
65
hello2
63
- fgets() took less than %d ms
64
66
hello3
65
- fgets() took less than %d ms
66
67
hello4
67
- fgets() took less than %d ms
68
68
hello5
69
- fgets() took less than %d ms
70
69
hello6
71
- fgets() took less than %d ms
72
70
hello7
73
- fgets() took less than %d ms
74
71
hello8
75
- fgets() took less than %d ms
76
72
hello9
77
- fgets() took less than %d ms
73
+ ===DONE===
0 commit comments