com php-src: added test for bug #69900: ext/standard/tests/stre ams/proc_open_bug69900.phpt
| From: | Anatol Belski | Date: | Thu, 02 Jul 2015 12:23:01 +0000 |
| Subject: | com php-src: added test for bug #69900: ext/standard/tests/stre ams/proc_open_bug69900.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87696@lists.php.net to get a copy of this message | ||
Commit: 5750058ddb18528909e1842985730b4e3223bcb0
Author: Anatol Belski <ab@php.net> Tue, 30 Jun 2015 19:22:17 +0200
Parents: aec332e6b4ecbc529def9256342ee4e57ca440f3
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5750058ddb18528909e1842985730b4e3223bcb0
Log:
added test for bug #69900
Bugs:
https://bugs.php.net/69900
Changed paths:
A ext/standard/tests/streams/proc_open_bug69900.phpt
Diff:
diff --git a/ext/standard/tests/streams/proc_open_bug69900.phpt
b/ext/standard/tests/streams/proc_open_bug69900.phpt
new file mode 100644
index 0000000..cbfc451
--- /dev/null
+++ b/ext/standard/tests/streams/proc_open_bug69900.phpt
@@ -0,0 +1,69 @@
+--TEST--
+Bug #69900 Commandline input/output weird behaviour with STDIO
+--FILE--
+<?php
+
+error_reporting(E_ALL);
+
+$fl = dirname(__FILE__) . DIRECTORY_SEPARATOR . "test69900.php";
+
+$test_content = '<?php
+
+$in = fopen("php://stdin", "rb", false,
stream_context_create(array("pipe" => array("blocking" => true))));
+
+while(!feof($in)){
+$s = fgets($in);
+ fwrite(STDOUT, $s);
+}
+
+?>';
+file_put_contents($fl, $test_content);
+
+$descriptorspec = array(0 => array("pipe", "r"),1 =>
array("pipe", "w"), 2 => array("file",
"error-output.txt", "a"));
+$pipes = array();
+
+$process = proc_open(PHP_BINARY.' -f ' . $fl, $descriptorspec, $pipes, NULL, NULL,
array("blocking_pipes" => true));
+
+for($i = 0; $i < 10; $i++){
+ fwrite($pipes[0], "hello$i\r\n");
+ fflush($pipes[0]);
+
+ $t0 = microtime(1);
+ $s = fgets($pipes[1]);
+ fflush($pipes[1]);
+ $t1 = microtime(1);
+
+ echo $s;
+ echo "fgets() took ", (($t1 - $t0)*1000), "ms\n";
+}
+
+fclose($pipes[0]);
+fclose($pipes[1]);
+
+proc_close($process);
+
+@unlink($fl);
+?>
+===DONE===
+--EXPECTF--
+hello0
+fgets() took %d.%dms
+hello1
+fgets() took 0.%dms
+hello2
+fgets() took 0.%dms
+hello3
+fgets() took 0.%dms
+hello4
+fgets() took 0.%dms
+hello5
+fgets() took 0.%dms
+hello6
+fgets() took 0.%dms
+hello7
+fgets() took 0.%dms
+hello8
+fgets() took 0.%dms
+hello9
+fgets() took 0.%dms
+===DONE===