summaryrefslogtreecommitdiff
path: root/ext/pcntl/tests
diff options
context:
space:
mode:
authorZoe Slattery <zoe@php.net>2009-08-26 17:17:58 +0000
committerZoe Slattery <zoe@php.net>2009-08-26 17:17:58 +0000
commit1c98e49afd36a73c01edf1124fc69bc38370c7e4 (patch)
treec92d8655bff4a3e09850b0cacd1113ff7d3daa0e /ext/pcntl/tests
parentc7167ced0bc5da4703c29f03a586988a97bff299 (diff)
downloadphp-git-1c98e49afd36a73c01edf1124fc69bc38370c7e4.tar.gz
Test from 2009 testfest
Diffstat (limited to 'ext/pcntl/tests')
-rw-r--r--ext/pcntl/tests/pcntl_fork_basic.phpt27
-rw-r--r--ext/pcntl/tests/pcntl_fork_variation.phpt48
2 files changed, 75 insertions, 0 deletions
diff --git a/ext/pcntl/tests/pcntl_fork_basic.phpt b/ext/pcntl/tests/pcntl_fork_basic.phpt
new file mode 100644
index 0000000000..82759ba327
--- /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 0000000000..4eea07181c
--- /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