From facd8866d8e2206588e7d2b48acdba4f54b282be Mon Sep 17 00:00:00 2001 From: andy wharmby Date: Mon, 15 Jun 2009 12:14:58 +0000 Subject: [PATCH] New POSIX extension tests from Berlin UG TestFest 2009. --- ext/posix/tests/posix_access.phpt | 48 +++++++++++++++++++ ext/posix/tests/posix_access_error_modes.phpt | 42 ++++++++++++++++ .../tests/posix_access_error_wrongparams.phpt | 39 +++++++++++++++ ext/posix/tests/posix_ctermid.phpt | 26 ++++++++++ ext/posix/tests/posix_getgrgid.phpt | 45 +++++++++++++++++ ext/posix/tests/posix_getgrgid_macosx.phpt | 23 +++++++++ .../tests/posix_getgrgid_wrongparams.phpt | 28 +++++++++++ ext/posix/tests/posix_getsid.phpt | 28 +++++++++++ ext/posix/tests/posix_getsid_error.phpt | 28 +++++++++++ ext/posix/tests/posix_mkfifo_wrongparams.phpt | 21 ++++++++ ext/posix/tests/posix_times.phpt | 33 +++++++++++++ ext/posix/tests/posix_ttyname.phpt | 26 ++++++++++ .../posix_ttyname_error_wrongparams.phpt | 37 ++++++++++++++ ext/posix/tests/posix_uname.phpt | 33 +++++++++++++ 14 files changed, 457 insertions(+) create mode 100644 ext/posix/tests/posix_access.phpt create mode 100644 ext/posix/tests/posix_access_error_modes.phpt create mode 100644 ext/posix/tests/posix_access_error_wrongparams.phpt create mode 100644 ext/posix/tests/posix_ctermid.phpt create mode 100644 ext/posix/tests/posix_getgrgid.phpt create mode 100644 ext/posix/tests/posix_getgrgid_macosx.phpt create mode 100644 ext/posix/tests/posix_getgrgid_wrongparams.phpt create mode 100644 ext/posix/tests/posix_getsid.phpt create mode 100644 ext/posix/tests/posix_getsid_error.phpt create mode 100644 ext/posix/tests/posix_mkfifo_wrongparams.phpt create mode 100644 ext/posix/tests/posix_times.phpt create mode 100644 ext/posix/tests/posix_ttyname.phpt create mode 100644 ext/posix/tests/posix_ttyname_error_wrongparams.phpt create mode 100644 ext/posix/tests/posix_uname.phpt diff --git a/ext/posix/tests/posix_access.phpt b/ext/posix/tests/posix_access.phpt new file mode 100644 index 0000000000..4c3202851d --- /dev/null +++ b/ext/posix/tests/posix_access.phpt @@ -0,0 +1,48 @@ +--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-- + +--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..e4e1358742 --- /dev/null +++ b/ext/posix/tests/posix_access_error_modes.phpt @@ -0,0 +1,42 @@ +--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-- + +--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..92910ad63a --- /dev/null +++ b/ext/posix/tests/posix_access_error_wrongparams.phpt @@ -0,0 +1,39 @@ +--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-- + +--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 binary 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_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..139c9bdec3 --- /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[b'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[b'gid'])) { + die('Array index "gid" does not exist.'); +} +var_dump($grp[b'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_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=== -- 2.40.0