diff options
author | Sean Finney <seanius@debian.org> | 2009-06-24 22:49:04 +0200 |
---|---|---|
committer | Sean Finney <seanius@debian.org> | 2009-06-24 22:49:04 +0200 |
commit | 84f4ca9b07fe5b73d840258f4aa7c1eb534c4253 (patch) | |
tree | 9829bd578af8a4a8b42b04277f9067e00dc5ad90 /ext/posix | |
parent | 6821b67124604da690c5e9276d5370d679c63ac8 (diff) | |
download | php-upstream/5.3.0_RC4.tar.gz |
Imported Upstream version 5.3.0~RC4upstream/5.3.0_RC4upstream/5.3.0.RC4
Diffstat (limited to 'ext/posix')
34 files changed, 962 insertions, 3 deletions
diff --git a/ext/posix/posix.c b/ext/posix/posix.c index d613f98d2..beedd3894 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: posix.c,v 1.70.2.3.2.16.2.14 2008/12/31 11:15:42 sebastian Exp $ */ +/* $Id: posix.c,v 1.70.2.3.2.16.2.15 2009/06/06 02:40:48 mattwil Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -310,7 +310,7 @@ const zend_function_entry posix_functions[] = { static PHP_MINFO_FUNCTION(posix) { php_info_print_table_start(); - php_info_print_table_row(2, "Revision", "$Revision: 1.70.2.3.2.16.2.14 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.70.2.3.2.16.2.15 $"); php_info_print_table_end(); } /* }}} */ @@ -892,7 +892,7 @@ PHP_FUNCTION(posix_mknod) #if defined(HAVE_MAKEDEV) || defined(makedev) php_dev = makedev(major, minor); #else - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can not create a block or character device, creating a normal file instead"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create a block or character device, creating a normal file instead"); #endif } } diff --git a/ext/posix/tests/posix_access.phpt b/ext/posix/tests/posix_access.phpt new file mode 100644 index 000000000..a427f8a19 --- /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-- +<?php +if (!extension_loaded('posix')) { + die('SKIP The posix extension is not loaded.'); +} +if (posix_geteuid() == 0) { + die('SKIP Cannot run test as root.'); +} +?> +--INI-- +safe_mode = 1 +--FILE-- +<?php +$filename = dirname(__FILE__) . '/foo.test'; +$fp = fopen($filename,"w"); +fwrite($fp,"foo"); +fclose($fp); + +chmod ($filename, 0000); +var_dump(posix_access($filename, POSIX_F_OK)); + +chmod ($filename, 0400); +var_dump(posix_access($filename, POSIX_R_OK)); + +chmod ($filename, 0600); +var_dump(posix_access($filename, POSIX_W_OK)); + +chmod ($filename, 0700); +var_dump(posix_access($filename, POSIX_X_OK)); +?> +===DONE=== +--CLEAN-- +<?php +$filename = dirname(__FILE__) . '/foo.test'; +chmod ($filename, 0700); +unlink($filename); +?> +--EXPECTF-- +PHP Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d +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 000000000..bfe366f81 --- /dev/null +++ b/ext/posix/tests/posix_access_error_modes.phpt @@ -0,0 +1,45 @@ +--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-- +<?php +if (!extension_loaded('posix')) { + die('SKIP The posix extension is not loaded.'); +} +if (posix_geteuid() == 0) { + die('SKIP Cannot run test as root.'); +} +?> +--INI-- +safe_mode = 1 +--FILE-- +<?php +$filename = dirname(__FILE__) . '/foo.test'; +var_dump(posix_access($filename, POSIX_F_OK)); +$fp = fopen($filename,"w"); +fwrite($fp,"foo"); +fclose($fp); + +chmod ($filename, 0000); +var_dump(posix_access($filename, POSIX_R_OK)); +var_dump(posix_access($filename, POSIX_W_OK)); +var_dump(posix_access($filename, POSIX_X_OK)); +?> +===DONE=== +--CLEAN-- +<?php +$filename = dirname(__FILE__) . '/foo.test'; +chmod ($filename, 0700); +unlink($filename); +?> +--EXPECTF-- +PHP Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line %d +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 000000000..04f933545 --- /dev/null +++ b/ext/posix/tests/posix_access_error_wrongparams.phpt @@ -0,0 +1,43 @@ +--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-- +<?php +if (!extension_loaded('posix')) { + die('SKIP The posix extension is not loaded.'); +} +if (posix_geteuid() == 0) { + die('SKIP Cannot run test as root.'); +} +?> +--INI-- +safe_mode = 1 +--FILE-- +<?php + +var_dump( posix_access() ); +var_dump( posix_access(array()) ); +var_dump( posix_access('foo',array()) ); +var_dump( posix_access(null) ); + +var_dump(posix_access('./foobar')); +?> +===DONE=== +--EXPECTF-- +PHP Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in Unknown on line 0 + +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 000000000..6055c8074 --- /dev/null +++ b/ext/posix/tests/posix_access_safemode.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test posix_access() with safe_mode enabled. +--CREDITS-- +Till Klampaeckel, till@php.net +TestFest Berlin 2009 +--SKIPIF-- +<?php +if (!extension_loaded('posix')) { + die('SKIP The posix extension is not loaded.'); +} +if (posix_geteuid() == 0) { + die('SKIP Cannot run test as root.'); +} +--INI-- +safe_mode = 1 +--FILE-- +<?php +var_dump(posix_access('/tmp', POSIX_W_OK)); +?> +===DONE=== +--EXPECTF-- +PHP Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d +bool(false) +===DONE=== diff --git a/ext/posix/tests/posix_ctermid.phpt b/ext/posix/tests/posix_ctermid.phpt new file mode 100644 index 000000000..f77da00aa --- /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-- +<?php + if (!extension_loaded('posix')) { + die('SKIP - POSIX extension not available'); + } + // needed because of #ifdef HAVE_CTERMID in posix.c + if (!function_exists('posix_ctermid')) { + die('SKIP - Fuction posix_ctermid() not available'); + } +?> +--FILE-- +<?php + var_dump(posix_ctermid()); +?> +===DONE=== +--EXPECTF-- +string(%d) "%s" +===DONE=== diff --git a/ext/posix/tests/posix_getcwd_basic.phpt b/ext/posix/tests/posix_getcwd_basic.phpt new file mode 100644 index 000000000..2477c376a --- /dev/null +++ b/ext/posix/tests/posix_getcwd_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +posix_getcwd(): Basic tests +--SKIPIF-- +<?php +if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +if (!function_exists('posix_getcwd')) die('skip posix_getcwd() not found'); +?> +--FILE-- +<?php +echo "Basic test of POSIX posix_getcwd function\n"; +var_dump(posix_getcwd()); +var_dump(posix_getcwd(1)); + +?> +===DONE=== +--EXPECTF-- +Basic test of POSIX posix_getcwd function +string(%d) "%s" + +Warning: posix_getcwd() expects exactly 0 parameters, 1 given in %s on line %d +NULL +===DONE=== diff --git a/ext/posix/tests/posix_getgrgid.phpt b/ext/posix/tests/posix_getgrgid.phpt new file mode 100644 index 000000000..0209d0973 --- /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-- +<?php +if (!extension_loaded('posix')) { + die('SKIP The posix extension is not loaded.'); +} +?> +--FILE-- +<?php +$grp = posix_getgrgid(0); +if (!isset($grp['name'])) { + die('Array index "name" does not exist.'); +} +if (!isset($grp['passwd'])) { + die('Array index "passwd" does not exist.'); +} +if (!isset($grp['members'])) { + die('Array index "members" does not exist.'); +} elseif (!is_array($grp['members'])) { + die('Array index "members" must be an array.'); +} else { + if (count($grp['members']) > 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_basic.phpt b/ext/posix/tests/posix_getgrgid_basic.phpt new file mode 100644 index 000000000..866e11681 --- /dev/null +++ b/ext/posix/tests/posix_getgrgid_basic.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test posix_getgrgid() function : basic functionality +--SKIPIF-- +<?php + if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +?> +--FILE-- +<?php + echo "Basic test of POSIX getgid and getgrid fucntions\n"; + + $gid = posix_getgid(); + $groupinfo = posix_getgrgid($gid); + + print_r($groupinfo); + +?> +===DONE=== +--EXPECTF-- +Basic test of POSIX getgid and getgrid fucntions +Array +( + [name] => %s + [passwd] => %s + [members] => Array +%a + + [gid] => %d +) +===DONE=== +
\ No newline at end of file diff --git a/ext/posix/tests/posix_getgrgid_macosx.phpt b/ext/posix/tests/posix_getgrgid_macosx.phpt new file mode 100644 index 000000000..f9e6cc1d5 --- /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-- +<?php +if (!extension_loaded('posix')) { + die('SKIP The posix extension is not loaded.'); +} +if (strtolower(PHP_OS) != 'darwin') { + die('SKIP This test requires MacOSX/Darwin.'); +} +?> +--FILE-- +<?php +$grp = posix_getgrgid(-1); +var_dump($grp['name']); +?> +===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 000000000..d1ff77d19 --- /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-- +<?php +if (!extension_loaded('posix')) { + die('SKIP The posix extension is not loaded.'); +} +if (strtolower(PHP_OS) == 'darwin') { + die('SKIP This test doesn\'t run on MacOSX/Darwin.'); +} +--FILE-- +<?php +$gid = PHP_INT_MAX; // obscene high gid +var_dump(posix_getgrgid($gid)); +var_dump(posix_getgrgid(-1)); +var_dump(posix_getgrgid()); +?> +===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_getgrnam_basic.phpt b/ext/posix/tests/posix_getgrnam_basic.phpt new file mode 100644 index 000000000..fd5bf2317 --- /dev/null +++ b/ext/posix/tests/posix_getgrnam_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +posix_getgrnam(): Basic tests +--SKIPIF-- +<?php +if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +if (!function_exists('posix_getgrnam')) die('skip posix_getgrnam() not found'); +?> +--FILE-- +<?php +echo "Basic test of POSIX posix_getgrnam function\n"; + +var_dump(posix_getgrnam(NULL)); +var_dump(posix_getgrnam(1)); +var_dump(posix_getgrnam('')); + +?> +===DONE=== +--EXPECT-- +Basic test of POSIX posix_getgrnam function +bool(false) +bool(false) +bool(false) +===DONE===
\ No newline at end of file diff --git a/ext/posix/tests/posix_getgroups_basic.phpt b/ext/posix/tests/posix_getgroups_basic.phpt new file mode 100644 index 000000000..f062468b4 --- /dev/null +++ b/ext/posix/tests/posix_getgroups_basic.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test posix_getgroups() function : basic functionality +--SKIPIF-- +<?php + if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +?> +--FILE-- +<?php + echo "Basic test of POSIX getgroups\n"; + + $groups = posix_getgroups(); + + if (!is_array($groups)) { + echo "TEST FAILED - array result expected\n"; + } else { + echo "TEST PASSED\n"; + } + +?> +===DONE=== +--EXPECT-- +Basic test of POSIX getgroups +TEST PASSED +===DONE===
\ No newline at end of file diff --git a/ext/posix/tests/posix_getpgid_basic.phpt b/ext/posix/tests/posix_getpgid_basic.phpt new file mode 100644 index 000000000..3195387b7 --- /dev/null +++ b/ext/posix/tests/posix_getpgid_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +Test posix_getpgid() function : basic functionality +--SKIPIF-- +<?php + if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +?> +--FILE-- +<?php + echo "Basic test of posix_getpgid function\n"; + + $pid = posix_getpid(); + $pgid = posix_getpgid($pid); + + var_dump($pgid); + +?> +===DONE==== +--EXPECTF-- +Basic test of posix_getpgid function +int(%d) +===DONE==== + +
\ No newline at end of file diff --git a/ext/posix/tests/posix_getpgrp_basic.phpt b/ext/posix/tests/posix_getpgrp_basic.phpt new file mode 100644 index 000000000..a737019a2 --- /dev/null +++ b/ext/posix/tests/posix_getpgrp_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test posix_getpgrp() function : basic functionality +--SKIPIF-- +<?php + if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +?> +--FILE-- +<?php + echo "Basic test of POSIX getpgrp function\n"; + + $pgrp = posix_getpgrp(); + + var_dump($pgrp); + +?> +===DONE==== +--EXPECTF-- +Basic test of POSIX getpgrp function +int(%d) +===DONE==== +
\ No newline at end of file diff --git a/ext/posix/tests/posix_getpid_basic.phpt b/ext/posix/tests/posix_getpid_basic.phpt new file mode 100644 index 000000000..a1444413e --- /dev/null +++ b/ext/posix/tests/posix_getpid_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test posix_getpid() function : basic functionality +--SKIPIF-- +<?php + if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +?> +--FILE-- +<?php + echo "Basic test of POSIX getpid function\n"; + + $pid = posix_getpid(); + + var_dump($pid); + +?> +===DONE==== +--EXPECTF-- +Basic test of POSIX getpid function +int(%d) +===DONE==== +
\ No newline at end of file diff --git a/ext/posix/tests/posix_getppid_basic.phpt b/ext/posix/tests/posix_getppid_basic.phpt new file mode 100644 index 000000000..2da591c17 --- /dev/null +++ b/ext/posix/tests/posix_getppid_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test posix_getppid() function : basic functionality +--SKIPIF-- +<?php + if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +?> +--FILE-- +<?php + echo "Basic test of POSIX getppid function\n"; + + $ppid = posix_getppid(); + + var_dump($ppid); + +?> +===DONE==== +--EXPECTF-- +Basic test of POSIX getppid function +int(%d) +===DONE==== +
\ No newline at end of file diff --git a/ext/posix/tests/posix_getpwnam_basic.phpt b/ext/posix/tests/posix_getpwnam_basic.phpt new file mode 100644 index 000000000..d675d6c18 --- /dev/null +++ b/ext/posix/tests/posix_getpwnam_basic.phpt @@ -0,0 +1,23 @@ +--TEST-- +posix_getpwnam(): Basic tests +--SKIPIF-- +<?php +if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +if (!function_exists('posix_getpwnam')) die('skip posix_getpwnam() not found'); +?> +--FILE-- +<?php +echo "Basic test of POSIX posix_getpwnam function\n"; + +var_dump(posix_getpwnam(1)); +var_dump(posix_getpwnam('')); +var_dump(posix_getpwnam(NULL)); + +?> +===DONE==== +--EXPECT-- +Basic test of POSIX posix_getpwnam function +bool(false) +bool(false) +bool(false) +===DONE==== diff --git a/ext/posix/tests/posix_getpwuid_basic.phpt b/ext/posix/tests/posix_getpwuid_basic.phpt new file mode 100644 index 000000000..1bcd59d0e --- /dev/null +++ b/ext/posix/tests/posix_getpwuid_basic.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test posix_getpwuid() function : basic functionality +--SKIPIF-- +<?php + if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +?> +--FILE-- +<?php + echo "Basic test of POSIX getpwuid\n"; + + + $pwuid = posix_getpwuid(posix_getuid()); + + print_r($pwuid); + +?> +===DONE==== +--EXPECTREGEX-- +Basic test of POSIX getpwuid +Array +\( + \[name\] => [^\r\n]+ + \[passwd\] => [^\r\n]+ + \[uid\] => [0-9]+ + \[gid\] => [0-9]+ + \[gecos\] => [^\r\n]* + \[dir\] => [^\r\n]+ + \[shell\] => [^\r\n]+ +\) +===DONE====
\ No newline at end of file diff --git a/ext/posix/tests/posix_getrlimit_basic.phpt b/ext/posix/tests/posix_getrlimit_basic.phpt new file mode 100644 index 000000000..7fdd0e7e4 --- /dev/null +++ b/ext/posix/tests/posix_getrlimit_basic.phpt @@ -0,0 +1,20 @@ +--TEST-- +posix_getrlimit(): Basic tests +--SKIPIF-- +<?php +if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +if (!function_exists('posix_getrlimit')) die('skip posix_getrlimit() not found'); +?> +--FILE-- +<?php +echo "Basic test of POSIX posix_getrlimit function\n"; +var_dump(posix_getrlimit()); + +?> +===DONE==== +--EXPECTF-- +Basic test of POSIX posix_getrlimit function +array(%d) { +%a +} +===DONE====
\ No newline at end of file diff --git a/ext/posix/tests/posix_getsid.phpt b/ext/posix/tests/posix_getsid.phpt new file mode 100644 index 000000000..62ed3c9eb --- /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-- +<?php + if(!extension_loaded("posix")) print "SKIP - POSIX extension not loaded"; +?> +--FILE-- +<?php +echo "*** Testing posix_getsid() : function test ***\n"; + +$pid = posix_getpid(); +echo "\n-- Testing posix_getsid() function with current process pid --\n"; +var_dump( is_long(posix_getsid($pid)) ); + +?> +===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_basic.phpt b/ext/posix/tests/posix_getsid_basic.phpt new file mode 100644 index 000000000..a53e1df8b --- /dev/null +++ b/ext/posix/tests/posix_getsid_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test posix_getsid() function : basic functionality +--SKIPIF-- +<?php + if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +?> +--FILE-- +<?php + echo "Basic test of posix_getsid function\n"; + + $pid = posix_getpid(); + $sid = posix_getsid($pid); + + var_dump($sid); + +?> +===DONE==== +--EXPECTF-- +Basic test of posix_getsid function +int(%d) +===DONE==== +
\ No newline at end of file diff --git a/ext/posix/tests/posix_getsid_error.phpt b/ext/posix/tests/posix_getsid_error.phpt new file mode 100644 index 000000000..445bc5a87 --- /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-- +<?php + if(!extension_loaded("posix")) { + die("SKIP - POSIX extension not loaded"); + } +?> +--FILE-- +<?php +var_dump( posix_getsid() ); +var_dump( posix_getsid(array()) ); +var_dump( posix_getsid(-1) ); +?> +===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_initgroups_basic.phpt b/ext/posix/tests/posix_initgroups_basic.phpt new file mode 100644 index 000000000..4a5005998 --- /dev/null +++ b/ext/posix/tests/posix_initgroups_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +posix_initgroups(): Basic tests +--SKIPIF-- +<?php +if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +if (!function_exists('posix_initgroups')) die('skip posix_initgroups() not found'); +?> +--FILE-- +<?php +echo "Basic test of POSIX posix_initgroups function\n"; +var_dump(posix_initgroups('foo', 'bar')); +var_dump(posix_initgroups(NULL, NULL)); + +?> +===DONE==== +--EXPECTF-- +Basic test of POSIX posix_initgroups function + +Warning: posix_initgroups() expects parameter 2 to be long, string given in %s on line %d +bool(false) +bool(false) +===DONE==== diff --git a/ext/posix/tests/posix_kill_basic.phpt b/ext/posix/tests/posix_kill_basic.phpt new file mode 100644 index 000000000..c995031af --- /dev/null +++ b/ext/posix/tests/posix_kill_basic.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test posix_kill(), posix_get_last_error and posix_strerror() functions : basic functionality +--SKIPIF-- +<?php + if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +?> +--FILE-- +<?php + echo "Basic test of POSIX getpgid(), kill(), get_last_error() and strerror() functions\n"; + + // Don't rely on PCNTL extension being around + $SIGKILL = 9; + + // TODO Once we have PS open working beef up this test to create a process and kill it + // for now start at a low pid and find first pid which does not exist. + $pid = 999; + do { + $pid += 1; + $result = shell_exec("ps -p " . $pid); + } while (stripos($result, (string)$pid) != FALSE); + + echo "Kill pid=" . $pid . "\n"; + var_dump(posix_kill($pid,$SIGKILL)); + + $errno = posix_get_last_error(); + + var_dump($errno); + var_dump(posix_strerror($errno)); + +?> +===DONE==== +--EXPECTF-- +Basic test of POSIX getpgid(), kill(), get_last_error() and strerror() functions +Kill pid=%d +bool(false) +int(%d) +string(%d) %sNo such process%s +===DONE==== +
\ No newline at end of file diff --git a/ext/posix/tests/posix_mkfifo_safemode.phpt b/ext/posix/tests/posix_mkfifo_safemode.phpt new file mode 100644 index 000000000..4cbcc6878 --- /dev/null +++ b/ext/posix/tests/posix_mkfifo_safemode.phpt @@ -0,0 +1,44 @@ +--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-- +<?php +if (!extension_loaded('posix')) { + die('SKIP The posix extension is not loaded.'); +} +if (posix_geteuid() == 0) { + die('SKIP Cannot run test as root.'); +} +?> +--INI-- +safe_mode = 1 +--FILE-- +<?php +var_dump(posix_mkfifo('/tmp/foobar', 0644)); + +$dir = dirname(__FILE__) . '/foo'; +mkdir ($dir); +var_dump(posix_mkfifo($dir . '/bar', 0644)); +?> +===DONE=== +--CLEAN-- +<?php +$dir = dirname(__FILE__) . '/foo'; +unlink($dir . '/bar'); +rmdir($dir); +?> +--EXPECTF-- +PHP Warning: Directive 'safe_mode' is deprecated in PHP 5.3 and greater in %s on line %d + +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 000000000..0d4df7b6e --- /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-- +<?php +if (!extension_loaded('posix')) { + die('SKIP The posix extension is not loaded.'); +} +?> +--FILE-- +<?php +posix_mkfifo(null); +var_dump(posix_mkfifo(null, 0644)); +?> +===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_mknod_basic.phpt b/ext/posix/tests/posix_mknod_basic.phpt new file mode 100644 index 000000000..bc3515646 --- /dev/null +++ b/ext/posix/tests/posix_mknod_basic.phpt @@ -0,0 +1,18 @@ +--TEST-- +posix_mknod(): Basic tests +--SKIPIF-- +<?php +if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +if (!function_exists('posix_mknod')) die('skip posix_mknod() not found'); +?> +--FILE-- +<?php +echo "Basic test of POSIX posix_mknod function\n"; +var_dump(posix_mknod(NULL, NULL, NULL, NULL)); + +?> +===DONE==== +--EXPECT-- +Basic test of POSIX posix_mknod function +bool(false) +===DONE====
\ No newline at end of file diff --git a/ext/posix/tests/posix_times.phpt b/ext/posix/tests/posix_times.phpt new file mode 100644 index 000000000..6ad3407cc --- /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-- +<?php + if (!extension_loaded('posix')) { + die('SKIP - POSIX extension not available'); + } +?> +--FILE-- +<?php + var_dump(posix_times()); +?> +===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_times_basic.phpt b/ext/posix/tests/posix_times_basic.phpt new file mode 100644 index 000000000..eb8af10df --- /dev/null +++ b/ext/posix/tests/posix_times_basic.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test posix_times() function : basic functionality +--SKIPIF-- +<?php + if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +?> +--FILE-- +<?php + echo "Basic test of POSIX times function\n"; + + $times = posix_times(); + + var_dump($times); + + + if ($times == FALSE) { + $errno= posix_get_last_error(); + var_dump(posix_strerror($errno)); + } + +?> +===DONE==== +--EXPECTF-- +Basic test of POSIX times function +array(5) { + ["ticks"]=> + int(%d) + ["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 000000000..76dff4e4c --- /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-- +<?php + if (!extension_loaded('posix')) { + die('SKIP - POSIX extension not available'); + } +?> +--FILE-- +<?php + var_dump(posix_ttyname(STDIN)); + var_dump(posix_ttyname(STDERR)); + var_dump(posix_ttyname(STDOUT)); +?> +===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 000000000..daa487f85 --- /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-- +<?php + if (!extension_loaded('posix')) { + die('SKIP - POSIX extension not available'); + } + if (!extension_loaded('gd')) { + die('SKIP - GD extension not available'); + } + if (!function_exists('imagecreate')) { + die('SKIP - Function imagecreate() not available'); + } +?> +--FILE-- +<?php + var_dump(posix_ttyname()); // param missing + var_dump(posix_ttyname(0)); // param not a ressource + var_dump(posix_ttyname(imagecreate(1, 1))); // wrong resource type +?> +===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 000000000..12c4baec1 --- /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-- +<?php + if (!extension_loaded('posix')) { + die('SKIP - POSIX extension not available'); + } +?> +--FILE-- +<?php + var_dump(posix_uname()); +?> +===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=== diff --git a/ext/posix/tests/posix_uname_basic.phpt b/ext/posix/tests/posix_uname_basic.phpt new file mode 100644 index 000000000..7dd378192 --- /dev/null +++ b/ext/posix/tests/posix_uname_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +Test posix_uname() function : basic functionality +--SKIPIF-- +<?php + if (!extension_loaded('posix')) die('skip - POSIX extension not loaded'); +?> +--FILE-- +<?php + echo "Basic test of POSIX uname function\n"; + + $uname = posix_uname(); + + print_r($uname); + +?> +===DONE==== +--EXPECTF-- +Basic test of POSIX uname function +Array +( + [sysname] => %s + [nodename] => %s + [release] => %s + [version] => %s + [machine] => %s +) +===DONE==== +
\ No newline at end of file |