summaryrefslogtreecommitdiff
path: root/ext/pcntl/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pcntl/tests')
-rw-r--r--ext/pcntl/tests/bug47566.phpt2
-rw-r--r--ext/pcntl/tests/pcntl_fork_basic.phpt27
-rw-r--r--ext/pcntl/tests/pcntl_fork_variation.phpt48
3 files changed, 76 insertions, 1 deletions
diff --git a/ext/pcntl/tests/bug47566.phpt b/ext/pcntl/tests/bug47566.phpt
index 8a69e6bc7..6eb3dbc13 100644
--- a/ext/pcntl/tests/bug47566.phpt
+++ b/ext/pcntl/tests/bug47566.phpt
@@ -3,7 +3,7 @@ Bug #47566 (return value of pcntl_wexitstatus())
--SKIPIF--
<?php if (!extension_loaded("pcntl")) print "skip"; ?>
--FILE--
-<?
+<?php
$pid = pcntl_fork();
if ($pid == -1) {
echo "Unable to fork";
diff --git a/ext/pcntl/tests/pcntl_fork_basic.phpt b/ext/pcntl/tests/pcntl_fork_basic.phpt
new file mode 100644
index 000000000..82759ba32
--- /dev/null
+++ b/ext/pcntl/tests/pcntl_fork_basic.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Test function pcntl_fork() by calling it with its expected arguments
+--CREDITS--
+Marco Fabbri mrfabbri@gmail.com
+Francesco Fullone ff@ideato.it
+#PHPTestFest Cesena Italia on 2009-06-20
+--SKIPIF--
+<?php
+ if (!extension_loaded('pcntl')) die('skip pcntl extension not available');
+ elseif (!extension_loaded('posix')) die('skip posix extension not available');
+?>
+--FILE--
+<?php
+echo "*** Test by calling method or function with its expected arguments, first print the child PID and the the father ***\n";
+
+$pid = pcntl_fork();
+if ($pid > 0) {
+ pcntl_wait($status);
+ var_dump($pid);
+} else {
+ var_dump($pid);
+}
+?>
+--EXPECTF--
+*** Test by calling method or function with its expected arguments, first print the child PID and the the father ***
+int(0)
+int(%d)
diff --git a/ext/pcntl/tests/pcntl_fork_variation.phpt b/ext/pcntl/tests/pcntl_fork_variation.phpt
new file mode 100644
index 000000000..4eea07181
--- /dev/null
+++ b/ext/pcntl/tests/pcntl_fork_variation.phpt
@@ -0,0 +1,48 @@
+--TEST--
+Test function pcntl_fork() by testing the process isolation in the forking hierarchy father -> son -> grandson where father can not knows his grandson
+--CREDITS--
+Marco Fabbri mrfabbri@gmail.com
+Francesco Fullone ff@ideato.it
+#PHPTestFest Cesena Italia on 2009-06-20
+--SKIPIF--
+<?php
+ if (!extension_loaded('pcntl')) die('skip pcntl extension not available');
+ elseif (!extension_loaded('posix')) die('skip posix extension not available');
+?>
+--FILE--
+<?php
+echo "*** Testing the process isolations between a process and its forks ***\n";
+
+$pid = pcntl_fork();
+
+if ($pid > 0) {
+ pcntl_wait($status);
+ echo "father is $pid\n";
+
+ if (!isset($pid2))
+ {
+ echo "father ($pid) doesn't know its grandsons\n";
+ }
+}
+else
+{
+ echo "son ($pid)\n";
+ $pid2 = pcntl_fork();
+ if ($pid2 > 0)
+ {
+ pcntl_wait($status2);
+ echo "son is father of $pid2\n";
+ }
+ else
+ {
+ echo "grandson ($pid2)\n";
+ }
+}
+?>
+--EXPECTF--
+*** Testing the process isolations between a process and its forks ***
+son (0)
+grandson (0)
+son is father of %d
+father is %d
+father (%d) doesn't know its grandsons