@@ -16,7 +16,7 @@ $php = getenv('TEST_PHP_EXECUTABLE');
16
16
if (!$ php ) {
17
17
die ("No php executable defined \n" );
18
18
}
19
- $ cmd = 'php -r "fwrite(STDOUT, $in = file_get_contents( \'php://stdin \')); fwrite(STDERR, $in);" ' ;
19
+ $ cmd = 'php -r "\ $in = file_get_contents( \'php://stdin \'); fwrite(STDOUT, \$in ); fwrite(STDERR, \ $in);" ' ;
20
20
$ descriptors = array (array ('pipe ' , 'r ' ), array ('pipe ' , 'w ' ), array ('pipe ' , 'w ' ));
21
21
$ stdin = str_repeat ('* ' , 2049 );
22
22
@@ -32,6 +32,7 @@ $stdinOffset = 0;
32
32
33
33
unset($ pipes [0 ]);
34
34
35
+ $ procOutput = [];
35
36
while ($ pipes || $ writePipes ) {
36
37
$ r = $ pipes ;
37
38
$ w = $ writePipes ;
@@ -48,6 +49,8 @@ while ($pipes || $writePipes) {
48
49
$ written = fwrite ($ writePipes [0 ], substr ($ stdin , $ stdinOffset ), 8192 );
49
50
if (false !== $ written ) {
50
51
$ stdinOffset += $ written ;
52
+ } else {
53
+ die ('Failed to write to pipe ' );
51
54
}
52
55
if ($ stdinOffset >= $ stdinLen ) {
53
56
fclose ($ writePipes [0 ]);
@@ -61,9 +64,17 @@ while ($pipes || $writePipes) {
61
64
if (false === $ data || feof ($ pipe )) {
62
65
fclose ($ pipe );
63
66
unset($ pipes [$ type ]);
67
+ } else {
68
+ $ resourceId = get_resource_id ($ pipe );
69
+ $ procOutput [$ resourceId ] = ($ procOutput [$ resourceId ] ?? '' ) . $ data ;
64
70
}
65
71
}
66
72
}
73
+ foreach ($ procOutput as $ output ) {
74
+ if ($ output !== $ stdin ) {
75
+ die ('Output does not match input ' );
76
+ }
77
+ }
67
78
echo "OK. " ;
68
79
?>
69
80
--EXPECT--
0 commit comments