@@ -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 ]);
@@ -58,12 +61,21 @@ while ($pipes || $writePipes) {
58
61
foreach ($ r as $ pipe ) {
59
62
$ type = array_search ($ pipe , $ pipes );
60
63
$ data = fread ($ pipe , 8192 );
61
- if (false === $ data || feof ($ pipe )) {
64
+ if (feof ($ pipe )) {
62
65
fclose ($ pipe );
63
66
unset($ pipes [$ type ]);
67
+ } elseif (false === $ data ) {
68
+ die ('Failed to read from pipe ' );
69
+ } else {
70
+ $ procOutput [$ type ] = ($ procOutput [$ type ] ?? '' ) . $ data ;
64
71
}
65
72
}
66
73
}
74
+ foreach ($ procOutput as $ output ) {
75
+ if ($ output !== $ stdin ) {
76
+ die ('Output does not match input: ' . $ output );
77
+ }
78
+ }
67
79
echo "OK. " ;
68
80
?>
69
81
--EXPECT--
0 commit comments