diff options
Diffstat (limited to 'ext/posix/tests')
19 files changed, 1543 insertions, 0 deletions
diff --git a/ext/posix/tests/posix_get_last_error_error.phpt b/ext/posix/tests/posix_get_last_error_error.phpt new file mode 100644 index 000000000..1089b440a --- /dev/null +++ b/ext/posix/tests/posix_get_last_error_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test posix_get_last_error() function : error conditions +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto int posix_get_last_error(void) + * Description: Retrieve the error number set by the last posix function which failed. + * Source code: ext/posix/posix.c + * Alias to functions: posix_errno + */ + +echo "*** Testing posix_get_last_error() : error conditions ***\n"; + +// One argument +echo "\n-- Testing posix_get_last_error() function with one argument --\n"; +$extra_arg = 10; +var_dump( posix_get_last_error($extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_get_last_error() : error conditions *** + +-- Testing posix_get_last_error() function with one argument -- + +Warning: Wrong parameter count for posix_get_last_error() in %s on line %d +NULL +Done diff --git a/ext/posix/tests/posix_getgid_error.phpt b/ext/posix/tests/posix_getgid_error.phpt new file mode 100644 index 000000000..8c1a4ec1e --- /dev/null +++ b/ext/posix/tests/posix_getgid_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test posix_getgid() function : error conditions +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto int posix_getgid(void) + * Description: Get the current group id (POSIX.1, 4.2.1) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +echo "*** Testing posix_getgid() : error conditions ***\n"; + +// One argument +echo "\n-- Testing posix_getgid() function with one argument --\n"; +$extra_arg = 10; +var_dump( posix_getgid($extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_getgid() : error conditions *** + +-- Testing posix_getgid() function with one argument -- + +Warning: Wrong parameter count for posix_getgid() in %s on line %d +NULL +Done diff --git a/ext/posix/tests/posix_getgrgid_error.phpt b/ext/posix/tests/posix_getgrgid_error.phpt new file mode 100644 index 000000000..bce624f45 --- /dev/null +++ b/ext/posix/tests/posix_getgrgid_error.phpt @@ -0,0 +1,53 @@ +--TEST-- +Test posix_getgrgid() function : error conditions +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto array posix_getgrgid(long gid) + * Description: Group database access (POSIX.1, 9.2.1) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +/* + * add a comment here to say what the test is supposed to do + */ + +echo "*** Testing posix_getgrgid() : error conditions ***\n"; + +// Zero arguments +echo "\n-- Testing posix_getgrgid() function with Zero arguments --\n"; +var_dump( posix_getgrgid() ); + +//Test posix_getgrgid with one more than the expected number of arguments +echo "\n-- Testing posix_getgrgid() function with more than expected no. of arguments --\n"; + +$extra_arg = 10; +$gid = 0; +var_dump( posix_getgrgid($gid, $extra_arg) ); + +echo "\n-- Testing posix_getgrgid() function with a negative group id --\n"; +$gid = -999; +var_dump( posix_getgrgid($gid)); + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_getgrgid() : error conditions *** + +-- Testing posix_getgrgid() function with Zero arguments -- + +Warning: posix_getgrgid() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing posix_getgrgid() function with more than expected no. of arguments -- + +Warning: posix_getgrgid() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +-- Testing posix_getgrgid() function with a negative group id -- +bool(false) +Done diff --git a/ext/posix/tests/posix_getgrgid_variation.phpt b/ext/posix/tests/posix_getgrgid_variation.phpt new file mode 100644 index 000000000..13db73b79 --- /dev/null +++ b/ext/posix/tests/posix_getgrgid_variation.phpt @@ -0,0 +1,175 @@ +--TEST-- +Test posix_getgrgid() function : usage variations - parameter types +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto array posix_getgrgid(long gid) + * Description: Group database access (POSIX.1, 9.2.1) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +echo "*** Testing posix_getgrgid() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // undefined data + $undefined_var, + + // unset data + $unset_var, + + // object data + new stdclass(), +); + +// loop through each element of the array for gid + +foreach($values as $value) { + echo "\nArg value $value \n"; + $result = posix_getgrgid($value); + if ((is_array($result) && (count($result) == 4)) + || + ($result === false)) { + echo "valid output\n"; + } else { + var_dump($result); + } +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_getgrgid() : usage variations *** + +Notice: Undefined variable: undefined_var in %s on line %d + +Notice: Undefined variable: unset_var in %s on line %d + +Arg value 10.5 +valid output + +Arg value -10.5 +valid output + +Arg value 101234567000 +valid output + +Arg value 1.07654321E-9 +valid output + +Arg value 0.5 +valid output + +Arg value Array + +Warning: posix_getgrgid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value Array + +Warning: posix_getgrgid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value Array + +Warning: posix_getgrgid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value Array + +Warning: posix_getgrgid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value Array + +Warning: posix_getgrgid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value +valid output + +Arg value +valid output + +Arg value 1 +valid output + +Arg value +valid output + +Arg value 1 +valid output + +Arg value +valid output + +Arg value + +Warning: posix_getgrgid() expects parameter 1 to be long, string given in %s on line %d +valid output + +Arg value + +Warning: posix_getgrgid() expects parameter 1 to be long, string given in %s on line %d +valid output + +Arg value string + +Warning: posix_getgrgid() expects parameter 1 to be long, string given in %s on line %d +valid output + +Arg value string + +Warning: posix_getgrgid() expects parameter 1 to be long, string given in %s on line %d +valid output + +Arg value +valid output + +Arg value +valid output + +Catchable fatal error: Object of class stdClass could not be converted to string in %s on line %d diff --git a/ext/posix/tests/posix_getpgid_error.phpt b/ext/posix/tests/posix_getpgid_error.phpt new file mode 100644 index 000000000..e703b8fdc --- /dev/null +++ b/ext/posix/tests/posix_getpgid_error.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test posix_getpgid() function : error conditions +--SKIPIF-- +<?php +if((!extension_loaded("posix")) || (!function_exists(posix_getpgid))) { + print "skip - POSIX extension not loaded or posix_getpgid() does not exist"; +} +?> +--FILE-- +<?php +/* Prototype : proto int posix_getpgid(void) + * Description: Get the process group id of the specified process (This is not a POSIX function, but a SVR4ism, so we compile conditionally) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +echo "*** Testing posix_getpgid() : error conditions ***\n"; + +echo "\n-- Testing posix_getpgid() function no arguments --\n"; +var_dump( posix_getpgid() ); + +echo "\n-- Testing posix_getpgid() with one extra argument --\n"; +$pid = 10; +$extra_arg = 20; +var_dump( posix_getpgid($pid, $extra_arg) ); + +echo "\n-- Testing posix_getpgid() with negative pid --\n"; +$pid = -99; +var_dump( posix_getpgid($pid) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_getpgid() : error conditions *** + +-- Testing posix_getpgid() function no arguments -- + +Warning: posix_getpgid() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing posix_getpgid() with one extra argument -- + +Warning: posix_getpgid() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +-- Testing posix_getpgid() with negative pid -- +bool(false) +Done diff --git a/ext/posix/tests/posix_getpgid_variation.phpt b/ext/posix/tests/posix_getpgid_variation.phpt new file mode 100644 index 000000000..34a4beb0a --- /dev/null +++ b/ext/posix/tests/posix_getpgid_variation.phpt @@ -0,0 +1,175 @@ +--TEST-- +Test posix_getpgid() function : variation +--SKIPIF-- +<?php +if((!extension_loaded("posix")) || (!function_exists(posix_getpgid))) { + print "skip - POSIX extension not loaded or posix_getpgid() does not exist"; +} +?> +--FILE-- +<?php +/* Prototype : proto int posix_getpgid(void) + * Description: Get the process group id of the specified process (This is not a POSIX function, but a SVR4ism, so we compile conditionally) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +echo "*** Testing posix_getpgid() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // undefined data + $undefined_var, + + // unset data + $unset_var, + + // object data + new stdclass(), +); + +// loop through each element of the array for gid + +foreach($values as $value) { + echo "\nArg value $value \n"; + $result = posix_getpgid($value); + if (is_int($result) || $result === false) { + echo "valid output\n"; + } else { + var_dump($result); + } +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_getpgid() : usage variations *** + +Notice: Undefined variable: undefined_var in %s on line %d + +Notice: Undefined variable: unset_var in %s on line %d + +Arg value 10.5 +valid output + +Arg value -10.5 +valid output + +Arg value 101234567000 +valid output + +Arg value 1.07654321E-9 +valid output + +Arg value 0.5 +valid output + +Arg value Array + +Warning: posix_getpgid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value Array + +Warning: posix_getpgid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value Array + +Warning: posix_getpgid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value Array + +Warning: posix_getpgid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value Array + +Warning: posix_getpgid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value +valid output + +Arg value +valid output + +Arg value 1 +valid output + +Arg value +valid output + +Arg value 1 +valid output + +Arg value +valid output + +Arg value + +Warning: posix_getpgid() expects parameter 1 to be long, string given in %s on line %d +valid output + +Arg value + +Warning: posix_getpgid() expects parameter 1 to be long, string given in %s on line %d +valid output + +Arg value string + +Warning: posix_getpgid() expects parameter 1 to be long, string given in %s on line %d +valid output + +Arg value string + +Warning: posix_getpgid() expects parameter 1 to be long, string given in %s on line %d +valid output + +Arg value +valid output + +Arg value +valid output + +Catchable fatal error: Object of class stdClass could not be converted to string in %s on line %d diff --git a/ext/posix/tests/posix_getpgrp_error.phpt b/ext/posix/tests/posix_getpgrp_error.phpt new file mode 100644 index 000000000..e3c071dd6 --- /dev/null +++ b/ext/posix/tests/posix_getpgrp_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test posix_getpgrp() function : error conditions +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto int posix_getpgrp(void) + * Description: Get current process group id (POSIX.1, 4.3.1) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +echo "*** Testing posix_getpgrp() : error conditions ***\n"; + +// One argument +echo "\n-- Testing posix_getpgrp() function with one argument --\n"; +$extra_arg = 10; +var_dump( posix_getpgrp($extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_getpgrp() : error conditions *** + +-- Testing posix_getpgrp() function with one argument -- + +Warning: Wrong parameter count for posix_getpgrp() in %s on line %d +NULL +Done diff --git a/ext/posix/tests/posix_getpid_error.phpt b/ext/posix/tests/posix_getpid_error.phpt new file mode 100644 index 000000000..460cc4254 --- /dev/null +++ b/ext/posix/tests/posix_getpid_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test posix_getpid() function : error conditions +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto int posix_getpid(void) + * Description: Get the current process id (POSIX.1, 4.1.1) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +echo "*** Testing posix_getpid() : error conditions ***\n"; + +// One argument +echo "\n-- Testing posix_getpid() function with one argument --\n"; +$extra_arg = 10; +var_dump( posix_getpid($extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_getpid() : error conditions *** + +-- Testing posix_getpid() function with one argument -- + +Warning: Wrong parameter count for posix_getpid() in %s on line %d +NULL +Done diff --git a/ext/posix/tests/posix_getppid_error.phpt b/ext/posix/tests/posix_getppid_error.phpt new file mode 100644 index 000000000..26426ac6a --- /dev/null +++ b/ext/posix/tests/posix_getppid_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test posix_getppid() function : error conditions +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto int posix_getppid(void) + * Description: Get the parent process id (POSIX.1, 4.1.1) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +echo "*** Testing posix_getppid() : error conditions ***\n"; + +// One argument +echo "\n-- Testing posix_getppid() function with one argument --\n"; +$extra_arg = 10; +var_dump( posix_getppid($extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_getppid() : error conditions *** + +-- Testing posix_getppid() function with one argument -- + +Warning: Wrong parameter count for posix_getppid() in %s on line %d +NULL +Done diff --git a/ext/posix/tests/posix_getpwuid_error.phpt b/ext/posix/tests/posix_getpwuid_error.phpt new file mode 100644 index 000000000..4920e4e9d --- /dev/null +++ b/ext/posix/tests/posix_getpwuid_error.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test posix_getpwuid() function : error conditions +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto array posix_getpwuid(long uid) + * Description: User database access (POSIX.1, 9.2.2) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +echo "*** Testing posix_getpwuid() : error conditions ***\n"; + +echo "\n-- Testing posix_getpwuid() function with Zero arguments --\n"; +var_dump( posix_getpwuid() ); + +echo "\n-- Testing posix_getpwuid() function with more than expected no. of arguments --\n"; +$uid = posix_getuid(); +$extra_arg = 10; +var_dump( posix_getpwuid($uid, $extra_arg) ); + +echo "\n-- Testing posix_getpwuid() function negative uid --\n"; +$uid = -99; +var_dump( posix_getpwuid($uid) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_getpwuid() : error conditions *** + +-- Testing posix_getpwuid() function with Zero arguments -- + +Warning: posix_getpwuid() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing posix_getpwuid() function with more than expected no. of arguments -- + +Warning: posix_getpwuid() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +-- Testing posix_getpwuid() function negative uid -- +bool(false) +Done diff --git a/ext/posix/tests/posix_getpwuid_variation.phpt b/ext/posix/tests/posix_getpwuid_variation.phpt new file mode 100644 index 000000000..8e91d6c31 --- /dev/null +++ b/ext/posix/tests/posix_getpwuid_variation.phpt @@ -0,0 +1,175 @@ +--TEST-- +Test posix_getpwuid() function : usage variations - parameter types +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto array posix_getpwuid(long uid) + * Description: User database access (POSIX.1, 9.2.2) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +echo "*** Testing posix_getpwuid() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // undefined data + $undefined_var, + + // unset data + $unset_var, + + // object data + new stdclass(), +); + +// loop through each element of the array for uid + +foreach($values as $value) { + echo "\nArg value $value \n"; + $result = posix_getpwuid($value); + if ((is_array($result) && (count($result) == 7)) + || + ($result === false)) { + echo "valid output\n"; + } else { + var_dump($result); + } +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_getpwuid() : usage variations *** + +Notice: Undefined variable: undefined_var in %s on line %d + +Notice: Undefined variable: unset_var in %s on line %d + +Arg value 10.5 +valid output + +Arg value -10.5 +valid output + +Arg value 101234567000 +valid output + +Arg value 1.07654321E-9 +valid output + +Arg value 0.5 +valid output + +Arg value Array + +Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value Array + +Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value Array + +Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value Array + +Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value Array + +Warning: posix_getpwuid() expects parameter 1 to be long, array given in %s on line %d +valid output + +Arg value +valid output + +Arg value +valid output + +Arg value 1 +valid output + +Arg value +valid output + +Arg value 1 +valid output + +Arg value +valid output + +Arg value + +Warning: posix_getpwuid() expects parameter 1 to be long, string given in %s on line %d +valid output + +Arg value + +Warning: posix_getpwuid() expects parameter 1 to be long, string given in %s on line %d +valid output + +Arg value string + +Warning: posix_getpwuid() expects parameter 1 to be long, string given in %s on line %d +valid output + +Arg value string + +Warning: posix_getpwuid() expects parameter 1 to be long, string given in %s on line %d +valid output + +Arg value +valid output + +Arg value +valid output + +Catchable fatal error: Object of class stdClass could not be converted to string in %s on line %d diff --git a/ext/posix/tests/posix_getuid_error.phpt b/ext/posix/tests/posix_getuid_error.phpt new file mode 100644 index 000000000..44c0b945b --- /dev/null +++ b/ext/posix/tests/posix_getuid_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test posix_getuid() function : error conditions +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto int posix_getuid(void) + * Description: Get the current user id (POSIX.1, 4.2.1) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +echo "*** Testing posix_getuid() : error conditions ***\n"; + +// One argument +echo "\n-- Testing posix_getuid() function with one argument --\n"; +$extra_arg = 10;; +var_dump( posix_getuid($extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_getuid() : error conditions *** + +-- Testing posix_getuid() function with one argument -- + +Warning: Wrong parameter count for posix_getuid() in %s on line %d +NULL +Done diff --git a/ext/posix/tests/posix_kill_error.phpt b/ext/posix/tests/posix_kill_error.phpt new file mode 100644 index 000000000..082b21d6a --- /dev/null +++ b/ext/posix/tests/posix_kill_error.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test posix_kill() function : error conditions +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto bool posix_kill(int pid, int sig) + * Description: Send a signal to a process (POSIX.1, 3.3.2) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + + +echo "*** Testing posix_kill() : error conditions ***\n"; + + +echo "\n-- Testing posix_kill() function with more than expected no. of arguments --\n"; +$pid = posix_getpid(); +$sig = 9; +$extra_arg = 10; +var_dump( posix_kill($pid, $sig, $extra_arg) ); + +echo "\n-- Testing posix_kill() function with less than expected no. of arguments --\n"; +$pid = posix_getpid(); +var_dump( posix_kill($pid) ); + +echo "\n-- Testing posix_kill() function with invalid signal --\n"; +$pid = posix_getpid(); +$sig = 999; +var_dump( posix_kill($pid, 999) ); + +echo "\n-- Testing posix_kill() function with negative pid --\n"; +$pid = -999; +$sig = 9; +var_dump( posix_kill($pid, 999) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_kill() : error conditions *** + +-- Testing posix_kill() function with more than expected no. of arguments -- + +Warning: posix_kill() expects exactly 2 parameters, 3 given in %s on line %d +bool(false) + +-- Testing posix_kill() function with less than expected no. of arguments -- + +Warning: posix_kill() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) + +-- Testing posix_kill() function with invalid signal -- +bool(false) + +-- Testing posix_kill() function with negative pid -- +bool(false) +Done diff --git a/ext/posix/tests/posix_kill_variation1.phpt b/ext/posix/tests/posix_kill_variation1.phpt new file mode 100644 index 000000000..46268f241 --- /dev/null +++ b/ext/posix/tests/posix_kill_variation1.phpt @@ -0,0 +1,173 @@ +--TEST-- +Test posix_kill() function : usage variations - first parameter type +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto bool posix_kill(int pid, int sig) + * Description: Send a signal to a process (POSIX.1, 3.3.2) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +/* + * add a comment here to say what the test is supposed to do + */ + +echo "*** Testing posix_kill() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) +$sig = -999; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // undefined data + $undefined_var, + + // unset data + $unset_var, + + // object data + new stdclass(), +); + +// loop through each element of the array for pid + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( posix_kill($value, $sig) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_kill() : usage variations *** + +Notice: Undefined variable: undefined_var in %s on line %d + +Notice: Undefined variable: unset_var in %s on line %d + +Arg value 10.5 +bool(false) + +Arg value -10.5 +bool(false) + +Arg value 101234567000 +bool(false) + +Arg value 1.07654321E-9 +bool(false) + +Arg value 0.5 +bool(false) + +Arg value Array + +Warning: posix_kill() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: posix_kill() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: posix_kill() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: posix_kill() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: posix_kill() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Arg value +bool(false) + +Arg value +bool(false) + +Arg value 1 +bool(false) + +Arg value +bool(false) + +Arg value 1 +bool(false) + +Arg value +bool(false) + +Arg value + +Warning: posix_kill() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Arg value + +Warning: posix_kill() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Arg value string + +Warning: posix_kill() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Arg value string + +Warning: posix_kill() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Arg value +bool(false) + +Arg value +bool(false) + +Catchable fatal error: Object of class stdClass could not be converted to string in %s on line %d diff --git a/ext/posix/tests/posix_kill_variation2.phpt b/ext/posix/tests/posix_kill_variation2.phpt new file mode 100644 index 000000000..aef9acd04 --- /dev/null +++ b/ext/posix/tests/posix_kill_variation2.phpt @@ -0,0 +1,173 @@ +--TEST-- +Test posix_kill() function : usage variations - second parameter type +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto bool posix_kill(int pid, int sig) + * Description: Send a signal to a process (POSIX.1, 3.3.2) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +/* + * add a comment here to say what the test is supposed to do + */ + +echo "*** Testing posix_kill() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) +$pid = -999; + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // undefined data + $undefined_var, + + // unset data + $unset_var, + + // object data + new stdclass(), +); + +// loop through each element of the array for sig + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( posix_kill($pid, $value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_kill() : usage variations *** + +Notice: Undefined variable: undefined_var in %s on line %d + +Notice: Undefined variable: unset_var in %s on line %d + +Arg value 10.5 +bool(false) + +Arg value -10.5 +bool(false) + +Arg value 101234567000 +bool(false) + +Arg value 1.07654321E-9 +bool(false) + +Arg value 0.5 +bool(false) + +Arg value Array + +Warning: posix_kill() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: posix_kill() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: posix_kill() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: posix_kill() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: posix_kill() expects parameter 2 to be long, array given in %s on line %d +bool(false) + +Arg value +bool(false) + +Arg value +bool(false) + +Arg value 1 +bool(false) + +Arg value +bool(false) + +Arg value 1 +bool(false) + +Arg value +bool(false) + +Arg value + +Warning: posix_kill() expects parameter 2 to be long, string given in %s on line %d +bool(false) + +Arg value + +Warning: posix_kill() expects parameter 2 to be long, string given in %s on line %d +bool(false) + +Arg value string + +Warning: posix_kill() expects parameter 2 to be long, string given in %s on line %d +bool(false) + +Arg value string + +Warning: posix_kill() expects parameter 2 to be long, string given in %s on line %d +bool(false) + +Arg value +bool(false) + +Arg value +bool(false) + +Catchable fatal error: Object of class stdClass could not be converted to string in %s on line %d diff --git a/ext/posix/tests/posix_strerror_error.phpt b/ext/posix/tests/posix_strerror_error.phpt new file mode 100644 index 000000000..6fc17ec0c --- /dev/null +++ b/ext/posix/tests/posix_strerror_error.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test posix_strerror() function : error conditions +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto string posix_strerror(int errno) + * Description: Retrieve the system error message associated with the given errno. + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +echo "*** Testing posix_strerror() : error conditions ***\n"; + +echo "\n-- Testing posix_strerror() function with Zero arguments --\n"; +var_dump( posix_strerror() ); + +echo "\n-- Testing posix_strerror() function with more than expected no. of arguments --\n"; +$errno = posix_get_last_error(); +$extra_arg = 10; +var_dump( posix_strerror($errno, $extra_arg) ); + +echo "\n-- Testing posix_strerror() function with invalid error number --\n"; +$errno = -999; +var_dump( posix_strerror($errno) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_strerror() : error conditions *** + +-- Testing posix_strerror() function with Zero arguments -- + +Warning: posix_strerror() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +-- Testing posix_strerror() function with more than expected no. of arguments -- + +Warning: posix_strerror() expects exactly 1 parameter, 2 given in %s on line %d +bool(false) + +-- Testing posix_strerror() function with invalid error number -- +string(%d) "Unknown error %d" +Done diff --git a/ext/posix/tests/posix_strerror_variation1.phpt b/ext/posix/tests/posix_strerror_variation1.phpt new file mode 100644 index 000000000..40cfab2aa --- /dev/null +++ b/ext/posix/tests/posix_strerror_variation1.phpt @@ -0,0 +1,172 @@ +--TEST-- +Test posix_strerror() function : usage variations +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto string posix_strerror(int errno) + * Description: Retrieve the system error message associated with the given errno. + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +/* + * add a comment here to say what the test is supposed to do + */ + +echo "*** Testing posix_strerror() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + +//array of values to iterate over +$values = array( + + // float data + 10.5, + -10.5, + 10.1234567e10, + 10.7654321E-10, + .5, + + // array data + array(), + array(0), + array(1), + array(1, 2), + array('color' => 'red', 'item' => 'pen'), + + // null data + NULL, + null, + + // boolean data + true, + false, + TRUE, + FALSE, + + // empty data + "", + '', + + // string data + "string", + 'string', + + // undefined data + $undefined_var, + + // unset data + $unset_var, + + // object data + new stdclass(), +); + +// loop through each element of the array for errno + +foreach($values as $value) { + echo "\nArg value $value \n"; + var_dump( posix_strerror($value) ); +}; + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_strerror() : usage variations *** + +Notice: Undefined variable: undefined_var in %s on line %d + +Notice: Undefined variable: unset_var in %s on line %d + +Arg value 10.5 +string(18) "No child processes" + +Arg value -10.5 +string(%d) "Unknown error %d" + +Arg value 101234567000 +string(%d) "Unknown error %d" + +Arg value 1.07654321E-9 +string(7) "Success" + +Arg value 0.5 +string(7) "Success" + +Arg value Array + +Warning: posix_strerror() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: posix_strerror() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: posix_strerror() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: posix_strerror() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Arg value Array + +Warning: posix_strerror() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Arg value +string(7) "Success" + +Arg value +string(7) "Success" + +Arg value 1 +string(23) "Operation not permitted" + +Arg value +string(7) "Success" + +Arg value 1 +string(23) "Operation not permitted" + +Arg value +string(7) "Success" + +Arg value + +Warning: posix_strerror() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Arg value + +Warning: posix_strerror() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Arg value string + +Warning: posix_strerror() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Arg value string + +Warning: posix_strerror() expects parameter 1 to be long, string given in %s on line %d +bool(false) + +Arg value +string(7) "Success" + +Arg value +string(7) "Success" + +Catchable fatal error: Object of class stdClass could not be converted to string in %s on line %d diff --git a/ext/posix/tests/posix_times_error.phpt b/ext/posix/tests/posix_times_error.phpt new file mode 100644 index 000000000..79b1f797c --- /dev/null +++ b/ext/posix/tests/posix_times_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test posix_times() function : error conditions +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto array posix_times(void) + * Description: Get process times (POSIX.1, 4.5.2) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +echo "*** Testing posix_times() : error conditions ***\n"; + +// One argument +echo "\n-- Testing posix_times() function with one argument --\n"; +$extra_arg = 10;; +var_dump( posix_times($extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_times() : error conditions *** + +-- Testing posix_times() function with one argument -- + +Warning: Wrong parameter count for posix_times() in %s on line %d +NULL +Done diff --git a/ext/posix/tests/posix_uname_error.phpt b/ext/posix/tests/posix_uname_error.phpt new file mode 100644 index 000000000..df531734f --- /dev/null +++ b/ext/posix/tests/posix_uname_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test posix_uname() function : error conditions +--SKIPIF-- +<?php + if(!extension_loaded("posix")) print "skip - POSIX extension not loaded"; +?> +--FILE-- +<?php +/* Prototype : proto array posix_uname(void) + * Description: Get system name (POSIX.1, 4.4.1) + * Source code: ext/posix/posix.c + * Alias to functions: + */ + +echo "*** Testing posix_uname() : error conditions ***\n"; + +// One argument +echo "\n-- Testing posix_uname() function with one argument --\n"; +$extra_arg = 10;; +var_dump( posix_uname($extra_arg) ); + +echo "Done"; +?> +--EXPECTF-- +*** Testing posix_uname() : error conditions *** + +-- Testing posix_uname() function with one argument -- + +Warning: Wrong parameter count for posix_uname() in %s on line %d +NULL +Done |
