diff options
Diffstat (limited to 'ext/pcntl/tests')
| -rw-r--r-- | ext/pcntl/tests/001.phpt | 5 | ||||
| -rw-r--r-- | ext/pcntl/tests/002.phpt | 1 | ||||
| -rw-r--r-- | ext/pcntl/tests/pcntl_getpriority_basic.phpt | 19 | ||||
| -rw-r--r-- | ext/pcntl/tests/pcntl_setpriority_basic.phpt | 23 | ||||
| -rw-r--r-- | ext/pcntl/tests/pcntl_unshare_01.phpt | 21 | ||||
| -rw-r--r-- | ext/pcntl/tests/pcntl_unshare_02.phpt | 31 | ||||
| -rw-r--r-- | ext/pcntl/tests/pcntl_unshare_03.phpt | 28 |
7 files changed, 127 insertions, 1 deletions
diff --git a/ext/pcntl/tests/001.phpt b/ext/pcntl/tests/001.phpt index 6aedbaf33b..b9587e1325 100644 --- a/ext/pcntl/tests/001.phpt +++ b/ext/pcntl/tests/001.phpt @@ -4,6 +4,9 @@ Test pcntl wait functionality <?php if (!extension_loaded("pcntl")) print "skip"; elseif (!function_exists("posix_kill")) print "skip posix_kill() not available"; + if (PHP_OS == "Darwin") { + die("skip do not run on darwin"); + } ?> --FILE-- <?php @@ -27,7 +30,7 @@ function test_exit_signal(){ $pid=pcntl_fork(); if ($pid==0) { - sleep(10); + while(1); exit; } else { $options=0; diff --git a/ext/pcntl/tests/002.phpt b/ext/pcntl/tests/002.phpt index ce61b7b7fe..7d40735ae5 100644 --- a/ext/pcntl/tests/002.phpt +++ b/ext/pcntl/tests/002.phpt @@ -6,6 +6,7 @@ pcntl: pcntl_sigprocmask(), pcntl_sigwaitinfo(), pcntl_sigtimedwait() elseif (!extension_loaded('posix')) die('skip posix extension not available'); elseif (!function_exists('pcntl_sigwaitinfo') or !function_exists('pcntl_sigtimedwait')) die('skip required functionality is not available'); elseif (!defined('CLD_EXITED')) die('skip CLD_EXITED not defined'); + elseif (getenv('SKIP_ASAN')) die('skip Fails intermittently under asan/msan'); ?> --FILE-- <?php diff --git a/ext/pcntl/tests/pcntl_getpriority_basic.phpt b/ext/pcntl/tests/pcntl_getpriority_basic.phpt new file mode 100644 index 0000000000..42cd0f730b --- /dev/null +++ b/ext/pcntl/tests/pcntl_getpriority_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +pcntl_getpriority() - Basic behaviour +--CREDITS-- +Er Galvão Abbott galvao@galvao.eti.br +# TestFest 2017 PHPRS PHP UG 2017-10-29 +--SKIPIF-- +<?php +if (!extension_loaded('pcntl')) { + die('skip - ext/pcntl not loaded'); +} else if (!function_exists('pcntl_getpriority')) { + die('skip - pcntl_getpriority doesn\'t exist'); +} +?> +--FILE-- +<?php +var_dump(pcntl_getpriority()); +?> +--EXPECTF-- +int(%d) diff --git a/ext/pcntl/tests/pcntl_setpriority_basic.phpt b/ext/pcntl/tests/pcntl_setpriority_basic.phpt new file mode 100644 index 0000000000..235b0ec9ce --- /dev/null +++ b/ext/pcntl/tests/pcntl_setpriority_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +pcntl_setpriority() - Basic behaviour +--CREDITS-- +Er Galvão Abbott galvao@galvao.eti.br +# TestFest 2017 PHPRS PHP UG 2017-10-31 +--SKIPIF-- +<?php +if (!extension_loaded('pcntl')) { + die('skip ext/pcntl not loaded'); +} +if (!function_exists('pcntl_setpriority')) { + die('skip pcntl_setpriority doesn\'t exist'); +} +if (!function_exists('posix_getuid') || posix_getuid() !== 0) { + die('skip this functions needs to run with superuser'); +} +?> +--FILE-- +<?php +var_dump(pcntl_setpriority(-5)); +?> +--EXPECT-- +bool(true) diff --git a/ext/pcntl/tests/pcntl_unshare_01.phpt b/ext/pcntl/tests/pcntl_unshare_01.phpt new file mode 100644 index 0000000000..d914723dc1 --- /dev/null +++ b/ext/pcntl/tests/pcntl_unshare_01.phpt @@ -0,0 +1,21 @@ +--TEST-- +pcntl_unshare() with CLONE_NEWUSER +--SKIPIF-- +<?php +if (!extension_loaded("pcntl")) die("skip"); +if (!extension_loaded("posix")) die("skip posix extension not available"); +if (!function_exists("pcntl_unshare")) die("skip pcntl_unshare is not available"); +if (!defined("CLONE_NEWUSER")) die("skip flag unavailable"); +if (pcntl_unshare(CLONE_NEWUSER) == false && pcntl_get_last_error() == PCNTL_EPERM) { + die("skip Insufficient previleges to use CLONE_NEWUSER"); +} + +--FILE-- +<?php + +$olduid = posix_getuid(); +pcntl_unshare(CLONE_NEWUSER); +$newuid = posix_getuid(); +var_dump($olduid === $newuid); +--EXPECT-- +bool(false) diff --git a/ext/pcntl/tests/pcntl_unshare_02.phpt b/ext/pcntl/tests/pcntl_unshare_02.phpt new file mode 100644 index 0000000000..bdcb6120ef --- /dev/null +++ b/ext/pcntl/tests/pcntl_unshare_02.phpt @@ -0,0 +1,31 @@ +--TEST-- +pcntl_unshare() with CLONE_NEWPID +--SKIPIF-- +<?php +if (!extension_loaded("pcntl")) die("skip"); +if (!extension_loaded("posix")) die("skip posix extension not available"); +if (!function_exists("pcntl_unshare")) die("skip pcntl_unshare is not available"); +if (!defined("CLONE_NEWPID")) die("skip flag unavailable"); +if (getenv("SKIP_ASAN")) die("skip asan chokes on this"); +if (posix_getuid() !== 0 && + (!defined("CLONE_NEWUSER") || + (pcntl_unshare(CLONE_NEWUSER) == false && pcntl_get_last_error() == PCNTL_EPERM))) { + die("skip Insufficient previleges to run test"); +} + +--FILE-- +<?php + +if(posix_getuid() !== 0) { + pcntl_unshare(CLONE_NEWUSER); +} + +var_dump(getmypid()); +pcntl_unshare(CLONE_NEWPID); +if(!pcntl_fork()) { + var_dump(getmypid()); + exit(); +} +--EXPECTF-- +int(%d) +int(1) diff --git a/ext/pcntl/tests/pcntl_unshare_03.phpt b/ext/pcntl/tests/pcntl_unshare_03.phpt new file mode 100644 index 0000000000..d69bd40d40 --- /dev/null +++ b/ext/pcntl/tests/pcntl_unshare_03.phpt @@ -0,0 +1,28 @@ +--TEST-- +pcntl_unshare() with CLONE_NEWNET +--SKIPIF-- +<?php +if (!extension_loaded("pcntl")) die("skip"); +if (!extension_loaded("posix")) die("skip posix extension not available"); +if (!function_exists("pcntl_unshare")) die("skip pcntl_unshare is not available"); +if (!defined("CLONE_NEWNET")) die("skip flag unavailable"); +if (posix_getuid() !== 0 && + (!defined("CLONE_NEWUSER") || + (pcntl_unshare(CLONE_NEWUSER) == false && pcntl_get_last_error() == PCNTL_EPERM))) { + die("skip Insufficient previleges to run test"); +} +if (getenv("SKIP_ONLINE_TESTS")) die("skip online test"); + +--FILE-- +<?php + +if(posix_getuid() !== 0) { + pcntl_unshare(CLONE_NEWUSER); +} + +var_dump(gethostbyname('php.net')); +pcntl_unshare(CLONE_NEWNET); +var_dump(gethostbyname('php.net')); +--EXPECTF-- +string(%d) %s +string(7) "php.net" |
