summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMoriyoshi Koizumi <moriyoshi@php.net>2003-07-13 08:03:46 +0000
committerMoriyoshi Koizumi <moriyoshi@php.net>2003-07-13 08:03:46 +0000
commitd33ffb78aa9ce2ed5a5e41aefaebbb4a47c1b998 (patch)
treeeb237df359a57d810ab3f5e5e23df87712092353 /ext
parented9c700d9bedfec1592340f9f498f7005f15bfa9 (diff)
downloadphp-git-d33ffb78aa9ce2ed5a5e41aefaebbb4a47c1b998.tar.gz
Added regression test for proc_open()
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/tests/file/proc_open01.phpt58
1 files changed, 58 insertions, 0 deletions
diff --git a/ext/standard/tests/file/proc_open01.phpt b/ext/standard/tests/file/proc_open01.phpt
new file mode 100644
index 0000000000..ab41a35819
--- /dev/null
+++ b/ext/standard/tests/file/proc_open01.phpt
@@ -0,0 +1,58 @@
+--TEST--
+proc_open() regression test 1 (proc_open() leak)
+--FILE--
+<?php
+$pipes = array(1, 2, 3);
+$orig_pipes = $pipes;
+$proc = proc_open(
+ $_ENV['TEST_PHP_EXECUTABLE'],
+ array(0 => array('pipe', 'r'), 1 => array('pipe', 'w')),
+ $pipes
+);
+if ($proc === false) {
+ print "something went wrong.\n";
+}
+var_dump($pipes);
+stream_set_blocking($pipes[1], FALSE);
+$test_string = "yay!\n";
+fwrite($pipes[0], $test_string);
+fflush($pipes[0]);
+fclose($pipes[0]);
+$cnt = '';
+for ($left = strlen($test_string); $left > 0;) {
+ $read_fds = array($pipes[1]);
+ $retval = stream_select($read_fds, $write_fds = NULL, $exp_fds = NULL, 1);
+ if ($retval === false) {
+ print "select() failed\n";
+ break;
+ }
+ if ($retval === 0) {
+ print "timed out\n";
+ break;
+ }
+ $buf = fread($pipes[1], 1024);
+ $cnt .= $buf;
+ $left -= strlen($buf);
+}
+var_dump($cnt);
+fclose($pipes[1]);
+proc_close($proc);
+var_dump($orig_pipes);
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ resource(%d) of type (stream)
+ [1]=>
+ resource(%d) of type (stream)
+}
+string(5) "yay!
+"
+array(3) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+ [2]=>
+ int(3)
+}