diff options
Diffstat (limited to 'ext/pcntl/tests/001.phpt')
| -rw-r--r-- | ext/pcntl/tests/001.phpt | 76 |
1 files changed, 63 insertions, 13 deletions
diff --git a/ext/pcntl/tests/001.phpt b/ext/pcntl/tests/001.phpt index af214d0f62..d2f9923b95 100644 --- a/ext/pcntl/tests/001.phpt +++ b/ext/pcntl/tests/001.phpt @@ -1,22 +1,72 @@ --TEST-- -Check for pcntl presence +Test pcntl wait functionality --SKIPIF-- <?php if (!extension_loaded("pcntl")) print "skip"; ?> --POST-- --GET-- --FILE-- <?php -echo "pcntl extension is available"; -/* - you can add regression tests for your extension here - - the output of your test code has to be equal to the - text in the --EXPECT-- section below for the tests - to pass, differences between the output and the - expected text are interpreted as failure - - see php4/tests/README for further information on - writing regression tests -*/ +function test_exit_waits(){ + print "\n\nTesting pcntl_wifexited and wexitstatus...."; + + $pid=pcntl_fork(); + if ($pid==0) { + sleep(1); + exit(-1); + } else { + $options=0; + pcntl_waitpid($pid, &$status, $options); + if ( pcntl_wifexited($status) ) print "\nExited With: ". pcntl_wexitstatus($status); + } +} + +function test_exit_signal(){ + print "\n\nTesting pcntl_wifsignaled...."; + + $pid=pcntl_fork(); + + if ($pid==0) { + sleep(10); + exit; + } else { + $options=0; + posix_kill($pid, SIGTERM); + pcntl_waitpid($pid, &$status, $options); + if ( pcntl_wifsignaled($status) ) print "\nProcess was terminated by signal : ". pcntl_wtermsig($status); + } +} + + +function test_stop_signal(){ + print "\n\nTesting pcntl_wifstopped and pcntl_wstopsig...."; + + $pid=pcntl_fork(); + + if ($pid==0) { + sleep(1); + exit; + } else { + $options=WUNTRACED; + posix_kill($pid, SIGSTOP); + pcntl_waitpid($pid, &$status, $options); + if ( pcntl_wifstopped($status) ) print "\nProcess was stoped by signal : ". pcntl_wstopsig($status); + posix_kill($pid, SIGCONT); + } +} + +print "Staring wait.h tests...."; +test_exit_waits(); +test_exit_signal(); +test_stop_signal(); ?> --EXPECT-- +Staring wait.h tests.... + +Testing pcntl_wifexited and wexitstatus....-1 +Exited With: -1 + +Testing pcntl_wifsignaled.... +Process was terminated by signal : 15 + +Testing pcntl_wifstopped and pcntl_wstopsig.... +Process was stoped by signal : 19 |
