diff options
| author | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-08-17 22:37:20 +0200 |
|---|---|---|
| committer | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-08-25 13:02:13 +0200 |
| commit | 3df306de94dd94d6520c6f95e96c692c3aa8173a (patch) | |
| tree | a5b3f45099f2dc6923a148edafb73ed30cefd244 /ext/pcntl/tests | |
| parent | 4a98b644131597f6744789355d10aa55a66eee8e (diff) | |
| download | php-git-3df306de94dd94d6520c6f95e96c692c3aa8173a.tar.gz | |
Promote warnings to exceptions in ext/pcntl
Closes GH-6004
Diffstat (limited to 'ext/pcntl/tests')
| -rw-r--r-- | ext/pcntl/tests/pcntl_getpriority_error.phpt | 23 | ||||
| -rw-r--r-- | ext/pcntl/tests/pcntl_setpriority_error.phpt | 23 | ||||
| -rw-r--r-- | ext/pcntl/tests/pcntl_signal.phpt | 32 | ||||
| -rw-r--r-- | ext/pcntl/tests/pcntl_unshare_01.phpt | 4 | ||||
| -rw-r--r-- | ext/pcntl/tests/pcntl_unshare_02.phpt | 2 | ||||
| -rw-r--r-- | ext/pcntl/tests/pcntl_unshare_04.phpt | 20 |
6 files changed, 89 insertions, 15 deletions
diff --git a/ext/pcntl/tests/pcntl_getpriority_error.phpt b/ext/pcntl/tests/pcntl_getpriority_error.phpt new file mode 100644 index 0000000000..5276d4df77 --- /dev/null +++ b/ext/pcntl/tests/pcntl_getpriority_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +pcntl_getpriority() - Wrong process identifier +--SKIPIF-- +<?php +if (!extension_loaded('pcntl')) { + die('skip ext/pcntl not loaded'); +} +if (!function_exists('pcntl_getpriority')) { + die('skip pcntl_getpriority doesn\'t exist'); +} +?> +--FILE-- +<?php + +try { + pcntl_getpriority(null, 42); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +?> +--EXPECT-- +pcntl_getpriority(): Argument #2 ($process_identifier) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS diff --git a/ext/pcntl/tests/pcntl_setpriority_error.phpt b/ext/pcntl/tests/pcntl_setpriority_error.phpt new file mode 100644 index 0000000000..d354ab2bc5 --- /dev/null +++ b/ext/pcntl/tests/pcntl_setpriority_error.phpt @@ -0,0 +1,23 @@ +--TEST-- +pcntl_setpriority() - Wrong process identifier +--SKIPIF-- +<?php +if (!extension_loaded('pcntl')) { + die('skip ext/pcntl not loaded'); +} +if (!function_exists('pcntl_setpriority')) { + die('skip pcntl_setpriority doesn\'t exist'); +} +?> +--FILE-- +<?php + +try { + pcntl_setpriority(0, null, 42); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +?> +--EXPECT-- +pcntl_setpriority(): Argument #3 ($process_identifier) must be one of PRIO_PGRP, PRIO_USER, or PRIO_PROCESS diff --git a/ext/pcntl/tests/pcntl_signal.phpt b/ext/pcntl/tests/pcntl_signal.phpt index cd55d9ad96..4b94064e2a 100644 --- a/ext/pcntl/tests/pcntl_signal.phpt +++ b/ext/pcntl/tests/pcntl_signal.phpt @@ -18,10 +18,24 @@ posix_kill(posix_getpid(), SIGUSR1); pcntl_signal_dispatch(); var_dump(pcntl_signal(SIGALRM, SIG_IGN)); -var_dump(pcntl_signal(-1, -1)); -var_dump(pcntl_signal(-1, function(){})); -var_dump(pcntl_signal(SIGALRM, "not callable")); +try { + pcntl_signal(-1, -1); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + pcntl_signal(-1, function(){}); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +try { + pcntl_signal(SIGALRM, "not callable"); +} catch (TypeError $exception) { + echo $exception->getMessage() . "\n"; +} /* test freeing queue in RSHUTDOWN */ posix_kill(posix_getpid(), SIGTERM); @@ -31,13 +45,7 @@ echo "ok\n"; signal dispatched got signal from %r\d+|nobody%r bool(true) - -Warning: pcntl_signal(): Invalid signal %s -bool(false) - -Warning: pcntl_signal(): Invalid signal %s -bool(false) - -Warning: pcntl_signal(): Specified handler "not callable" is not callable (%s) in %s -bool(false) +pcntl_signal(): Argument #1 ($signo) must be greater than or equal to 1 +pcntl_signal(): Argument #1 ($signo) must be greater than or equal to 1 +pcntl_signal(): Argument #2 ($handler) must be of type callable|int, string given ok diff --git a/ext/pcntl/tests/pcntl_unshare_01.phpt b/ext/pcntl/tests/pcntl_unshare_01.phpt index 6debaace58..fcbf112e4d 100644 --- a/ext/pcntl/tests/pcntl_unshare_01.phpt +++ b/ext/pcntl/tests/pcntl_unshare_01.phpt @@ -7,9 +7,9 @@ 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"); + die("skip Insufficient privileges to use CLONE_NEWUSER"); } - +?> --FILE-- <?php diff --git a/ext/pcntl/tests/pcntl_unshare_02.phpt b/ext/pcntl/tests/pcntl_unshare_02.phpt index 7cc9341154..fdf07bc81c 100644 --- a/ext/pcntl/tests/pcntl_unshare_02.phpt +++ b/ext/pcntl/tests/pcntl_unshare_02.phpt @@ -15,7 +15,7 @@ if (posix_getuid() !== 0 && if (@pcntl_unshare(CLONE_NEWPID) == false && pcntl_get_last_error() == PCNTL_EPERM) { die("skip Insufficient privileges for CLONE_NEWPID"); } - +?> --FILE-- <?php diff --git a/ext/pcntl/tests/pcntl_unshare_04.phpt b/ext/pcntl/tests/pcntl_unshare_04.phpt new file mode 100644 index 0000000000..fdd47d5d66 --- /dev/null +++ b/ext/pcntl/tests/pcntl_unshare_04.phpt @@ -0,0 +1,20 @@ +--TEST-- +pcntl_unshare() with wrong flag +--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"); +?> +--FILE-- +<?php + +try { + pcntl_unshare(42); +} catch (ValueError $exception) { + echo $exception->getMessage() . "\n"; +} + +?> +--EXPECT-- +pcntl_unshare(): Argument #1 ($flags) must be a combination of CLONE_* flags |
