@@ -6,6 +6,7 @@ $php = getenv('TEST_PHP_EXECUTABLE');
66if (!$ php ) {
77 die ("skip No php executable defined \n" );
88}
9+ if (PHP_OS_FAMILY === 'Windows ' ) die ('skip not for Windows ' );
910?>
1011--FILE--
1112<?php
@@ -16,7 +17,7 @@ $php = getenv('TEST_PHP_EXECUTABLE');
1617if (!$ php ) {
1718 die ("No php executable defined \n" );
1819}
19- $ cmd = ' php -r "fwrite(STDOUT, $in = file_get_contents( \'php://stdin \')); fwrite(STDERR, $in);" ' ;
20+ $ cmd = $ php . ' -r "\ $in = file_get_contents( \'php://stdin \'); fwrite(STDOUT, \$in ); fwrite(STDERR, \ $in);" ' ;
2021$ descriptors = array (array ('pipe ' , 'r ' ), array ('pipe ' , 'w ' ), array ('pipe ' , 'w ' ));
2122$ stdin = str_repeat ('* ' , 2049 );
2223
@@ -32,6 +33,7 @@ $stdinOffset = 0;
3233
3334unset($ pipes [0 ]);
3435
36+ $ procOutput = [];
3537while ($ pipes || $ writePipes ) {
3638 $ r = $ pipes ;
3739 $ w = $ writePipes ;
@@ -48,6 +50,8 @@ while ($pipes || $writePipes) {
4850 $ written = fwrite ($ writePipes [0 ], substr ($ stdin , $ stdinOffset ), 8192 );
4951 if (false !== $ written ) {
5052 $ stdinOffset += $ written ;
53+ } else {
54+ die ('Failed to write to pipe ' );
5155 }
5256 if ($ stdinOffset >= $ stdinLen ) {
5357 fclose ($ writePipes [0 ]);
@@ -58,12 +62,21 @@ while ($pipes || $writePipes) {
5862 foreach ($ r as $ pipe ) {
5963 $ type = array_search ($ pipe , $ pipes );
6064 $ data = fread ($ pipe , 8192 );
61- if (false === $ data || feof ($ pipe )) {
65+ if (feof ($ pipe )) {
6266 fclose ($ pipe );
6367 unset($ pipes [$ type ]);
68+ } elseif (false === $ data ) {
69+ die ('Failed to read from pipe ' );
70+ } else {
71+ $ procOutput [$ type ] = ($ procOutput [$ type ] ?? '' ) . $ data ;
6472 }
6573 }
6674}
75+ foreach ($ procOutput as $ output ) {
76+ if ($ output !== $ stdin ) {
77+ die ('Output does not match input: ' . $ output );
78+ }
79+ }
6780echo "OK. " ;
6881?>
6982--EXPECT--
0 commit comments