From: andy wharmby Date: Mon, 15 Jun 2009 12:14:59 +0000 (+0000) Subject: New POSIX extension tests from Berlin UG TestFest 2009. X-Git-Tag: php-5.2.10~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=04961ad0c0fe3d7e4b668bbe7493206c03a70d1d;p=php New POSIX extension tests from Berlin UG TestFest 2009. --- diff --git a/ext/posix/tests/posix_access.phpt b/ext/posix/tests/posix_access.phpt new file mode 100644 index 0000000000..7082924b6e --- /dev/null +++ b/ext/posix/tests/posix_access.phpt @@ -0,0 +1,51 @@ +--TEST-- +Test posix_access() function test +--DESCRIPTION-- +checks for existence, read-access, write-access, execute-access +--CREDITS-- +Moritz Neuhaeuser, info@xcompile.net +PHP Testfest Berlin 2009-05-10 +--SKIPIF-- + +--INI-- +safe_mode = 1 +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +bool(true) +bool(true) +bool(true) +bool(true) +===DONE=== diff --git a/ext/posix/tests/posix_access_error_modes.phpt b/ext/posix/tests/posix_access_error_modes.phpt new file mode 100644 index 0000000000..6e0d5dce82 --- /dev/null +++ b/ext/posix/tests/posix_access_error_modes.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test posix_access() function test error conditions +--DESCRIPTION-- +checks if posix_access() failes for wrong permissions +--CREDITS-- +Moritz Neuhaeuser, info@xcompile.net +PHP Testfest Berlin 2009-05-10 +--SKIPIF-- + +--INI-- +safe_mode = 1 +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- +bool(false) +bool(false) +bool(false) +bool(false) +===DONE=== diff --git a/ext/posix/tests/posix_access_error_wrongparams.phpt b/ext/posix/tests/posix_access_error_wrongparams.phpt new file mode 100644 index 0000000000..56a2a65475 --- /dev/null +++ b/ext/posix/tests/posix_access_error_wrongparams.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test posix_access() function : parameter validation +--DESCRIPTION-- +cases: no params, wrong param1, wrong param2, null directory, wrong directory, +--CREDITS-- +Moritz Neuhaeuser, info@xcompile.net +PHP Testfest Berlin 2009-05-10 +--SKIPIF-- + +--INI-- +safe_mode = 1 +--FILE-- + +===DONE=== +--EXPECTF-- + +Warning: posix_access() expects at least 1 parameter, 0 given in %s on line %d +bool(false) + +Warning: posix_access() expects parameter 1 to be string, array given in %s on line %d +bool(false) + +Warning: posix_access() expects parameter 2 to be long, array given in %s on line %d +bool(false) +bool(false) +bool(false) +===DONE=== diff --git a/ext/posix/tests/posix_access_safemode.phpt b/ext/posix/tests/posix_access_safemode.phpt new file mode 100644 index 0000000000..51baf186d2 --- /dev/null +++ b/ext/posix/tests/posix_access_safemode.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test posix_access() with safe_mode enabled. +--CREDITS-- +Till Klampaeckel, till@php.net +TestFest Berlin 2009 +--SKIPIF-- + +===DONE=== +--EXPECTF-- +bool(false) +===DONE=== diff --git a/ext/posix/tests/posix_ctermid.phpt b/ext/posix/tests/posix_ctermid.phpt new file mode 100644 index 0000000000..f77da00aab --- /dev/null +++ b/ext/posix/tests/posix_ctermid.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test posix_ctermid() +--DESCRIPTION-- +Gets path name of controlling terminal. +Source code: ext/posix/posix.c +--CREDITS-- +Falko Menge, mail at falko-menge dot de +PHP Testfest Berlin 2009-05-10 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +string(%d) "%s" +===DONE=== diff --git a/ext/posix/tests/posix_getgrgid.phpt b/ext/posix/tests/posix_getgrgid.phpt new file mode 100644 index 0000000000..0209d09732 --- /dev/null +++ b/ext/posix/tests/posix_getgrgid.phpt @@ -0,0 +1,45 @@ +--TEST-- +Test posix_getgrgid(). +--CREDITS-- +Till Klampaeckel, till@php.net +TestFest Berlin 2009 +--SKIPIF-- + +--FILE-- + 0) { + foreach ($grp['members'] as $idx => $username) { + if (!is_int($idx)) { + die('Index in members Array is not an int.'); + } + if (!is_string($username)) { + die('Username in members Array is not of type string.'); + } + } + } +} +if (!isset($grp['gid'])) { + die('Array index "gid" does not exist.'); +} +var_dump($grp['gid']); +?> +===DONE=== +--EXPECT-- +int(0) +===DONE=== diff --git a/ext/posix/tests/posix_getgrgid_macosx.phpt b/ext/posix/tests/posix_getgrgid_macosx.phpt new file mode 100644 index 0000000000..f9e6cc1d53 --- /dev/null +++ b/ext/posix/tests/posix_getgrgid_macosx.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test return values of posix_getgrgid() on MacOSX. +--CREDITS-- +Till Klampaeckel, till@php.net +TestFest Berlin 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECT-- +string(7) "nogroup" +===DONE=== diff --git a/ext/posix/tests/posix_getgrgid_wrongparams.phpt b/ext/posix/tests/posix_getgrgid_wrongparams.phpt new file mode 100644 index 0000000000..d1ff77d193 --- /dev/null +++ b/ext/posix/tests/posix_getgrgid_wrongparams.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test parameters on posix_getgrgid(). +--CREDITS-- +Till Klampaeckel, till@php.net +TestFest Berlin 2009 +--SKIPIF-- + +===DONE=== +--EXPECTF-- +bool(false) +bool(false) + +Warning: posix_getgrgid() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/posix/tests/posix_getsid.phpt b/ext/posix/tests/posix_getsid.phpt new file mode 100644 index 0000000000..62ed3c9ebd --- /dev/null +++ b/ext/posix/tests/posix_getsid.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test posix_getsid() function test +--DESCRIPTION-- +Get the current session id of a process pid (POSIX.1, 4.2.1) +Source code: ext/posix/posix.c +--CREDITS-- +Moritz Neuhaeuser, info@xcompile.net +PHP Testfest Berlin 2009-05-10 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +*** Testing posix_getsid() : function test *** + +-- Testing posix_getsid() function with current process pid -- +bool(true) +===DONE=== diff --git a/ext/posix/tests/posix_getsid_error.phpt b/ext/posix/tests/posix_getsid_error.phpt new file mode 100644 index 0000000000..445bc5a876 --- /dev/null +++ b/ext/posix/tests/posix_getsid_error.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test posix_getsid() function : error conditions +--DESCRIPTION-- +cases: no params, wrong param, wrong param range +--CREDITS-- +Moritz Neuhaeuser, info@xcompile.net +PHP Testfest Berlin 2009-05-10 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: posix_getsid() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) + +Warning: posix_getsid() expects parameter 1 to be long, array given in %s on line %d +bool(false) +bool(false) +===DONE=== diff --git a/ext/posix/tests/posix_mkfifo_safemode.phpt b/ext/posix/tests/posix_mkfifo_safemode.phpt new file mode 100644 index 0000000000..6a928f8bc8 --- /dev/null +++ b/ext/posix/tests/posix_mkfifo_safemode.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test posix_mkfifo() with safe_mode. +--DESCRIPTION-- +The test attempts to enable safe_mode, catches all the relevant E_WARNING's and tries to create a fifo in /tmp. + +The first attempt (writing to /tmp) should effectively fail because /tmp is owned by root. + +The second attempt (writing to a local created file) works. +--CREDITS-- +Till Klampaeckel, till@php.net +TestFest Berlin 2009 +--SKIPIF-- + +--INI-- +safe_mode = 1 +--FILE-- + +===DONE=== +--CLEAN-- + +--EXPECTF-- + +Warning: posix_mkfifo(): SAFE MODE Restriction in effect. The script whose uid is %d is not allowed to access /tmp owned by uid %d in %s on line %d +bool(false) +bool(true) +===DONE=== diff --git a/ext/posix/tests/posix_mkfifo_wrongparams.phpt b/ext/posix/tests/posix_mkfifo_wrongparams.phpt new file mode 100644 index 0000000000..0d4df7b6e6 --- /dev/null +++ b/ext/posix/tests/posix_mkfifo_wrongparams.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test parameter validation in posix_mkfifo(). +--CREDITS-- +Till Klampaeckel, till@php.net +TestFest Berlin 2009 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: posix_mkfifo() expects exactly 2 parameters, 1 given in %s on line %d +bool(false) +===DONE=== diff --git a/ext/posix/tests/posix_times.phpt b/ext/posix/tests/posix_times.phpt new file mode 100644 index 0000000000..6ad3407ccb --- /dev/null +++ b/ext/posix/tests/posix_times.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test posix_times() +--DESCRIPTION-- +Gets information about the current CPU usage. +Source code: ext/posix/posix.c +--CREDITS-- +Falko Menge, mail at falko-menge dot de +PHP Testfest Berlin 2009-05-10 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +array(5) { + ["ticks"]=> + int(%i) + ["utime"]=> + int(%d) + ["stime"]=> + int(%d) + ["cutime"]=> + int(%d) + ["cstime"]=> + int(%d) +} +===DONE=== diff --git a/ext/posix/tests/posix_ttyname.phpt b/ext/posix/tests/posix_ttyname.phpt new file mode 100644 index 0000000000..76dff4e4c0 --- /dev/null +++ b/ext/posix/tests/posix_ttyname.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test posix_ttyname() +--DESCRIPTION-- +Gets the absolute path to the current terminal device that is open on a given file descriptor. +Source code: ext/posix/posix.c +--CREDITS-- +Falko Menge, mail at falko-menge dot de +PHP Testfest Berlin 2009-05-10 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +bool(false) +bool(false) +bool(false) +===DONE=== diff --git a/ext/posix/tests/posix_ttyname_error_wrongparams.phpt b/ext/posix/tests/posix_ttyname_error_wrongparams.phpt new file mode 100644 index 0000000000..daa487f853 --- /dev/null +++ b/ext/posix/tests/posix_ttyname_error_wrongparams.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test posix_ttyname() with wrong parameters +--DESCRIPTION-- +Gets the absolute path to the current terminal device that is open on a given file descriptor. +Source code: ext/posix/posix.c +--CREDITS-- +Falko Menge, mail at falko-menge dot de +PHP Testfest Berlin 2009-05-10 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +Warning: posix_ttyname() expects exactly 1 parameter, 0 given in %s on line %d +bool(false) +bool(false) + +Warning: posix_ttyname(): supplied resource is not a valid stream resource in %s on line %s + +Warning: posix_ttyname(): expects argument 1 to be a valid stream resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/posix/tests/posix_uname.phpt b/ext/posix/tests/posix_uname.phpt new file mode 100644 index 0000000000..12c4baec16 --- /dev/null +++ b/ext/posix/tests/posix_uname.phpt @@ -0,0 +1,33 @@ +--TEST-- +Test posix_uname() +--DESCRIPTION-- +Gets information about the system. +Source code: ext/posix/posix.c +--CREDITS-- +Falko Menge, mail at falko-menge dot de +PHP Testfest Berlin 2009-05-10 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +array(5) { + ["sysname"]=> + string(%d) "%s" + ["nodename"]=> + string(%d) "%s" + ["release"]=> + string(%d) "%s" + ["version"]=> + string(%d) "%s" + ["machine"]=> + string(%d) "%s" +} +===DONE===