diff options
author | andy wharmby <wharmby@php.net> | 2009-06-11 12:31:00 +0000 |
---|---|---|
committer | andy wharmby <wharmby@php.net> | 2009-06-11 12:31:00 +0000 |
commit | ec0cff39c7cf6328e28d2ba0f634222c1fc4f218 (patch) | |
tree | 210bbc1a0f1f1da56ebea7d5678bafaa973b4801 /ext/posix | |
parent | 11340cf29930cac9fe81cac97055f8455183aa57 (diff) | |
download | php-git-ec0cff39c7cf6328e28d2ba0f634222c1fc4f218.tar.gz |
New POISX tests. Tested on Windows (all test SKIP), Linux and Linux 64
Diffstat (limited to 'ext/posix')
-rw-r--r-- | ext/posix/tests/posix_getcwd_basic.phpt | 22 | ||||
-rw-r--r-- | ext/posix/tests/posix_getgrgid_basic.phpt | 30 | ||||
-rw-r--r-- | ext/posix/tests/posix_getgrnam_basic.phpt | 23 | ||||
-rw-r--r-- | ext/posix/tests/posix_getgroups_basic.phpt | 24 | ||||
-rw-r--r-- | ext/posix/tests/posix_getpgid_basic.phpt | 23 | ||||
-rw-r--r-- | ext/posix/tests/posix_getpgrp_basic.phpt | 21 | ||||
-rw-r--r-- | ext/posix/tests/posix_getpid_basic.phpt | 21 | ||||
-rw-r--r-- | ext/posix/tests/posix_getppid_basic.phpt | 21 | ||||
-rw-r--r-- | ext/posix/tests/posix_getpwnam_basic.phpt | 23 | ||||
-rw-r--r-- | ext/posix/tests/posix_getpwuid_basic.phpt | 30 | ||||
-rw-r--r-- | ext/posix/tests/posix_getrlimit_basic.phpt | 20 | ||||
-rw-r--r-- | ext/posix/tests/posix_getsid_basic.phpt | 22 | ||||
-rw-r--r-- | ext/posix/tests/posix_initgroups_basic.phpt | 22 | ||||
-rw-r--r-- | ext/posix/tests/posix_kill_basic.phpt | 39 | ||||
-rw-r--r-- | ext/posix/tests/posix_mknod_basic.phpt | 18 | ||||
-rw-r--r-- | ext/posix/tests/posix_strerror_error_basic.phpt | 46 | ||||
-rw-r--r-- | ext/posix/tests/posix_times_basic.phpt | 37 | ||||
-rw-r--r-- | ext/posix/tests/posix_uname_basic.phpt | 28 |
18 files changed, 470 insertions, 0 deletions
diff --git a/ext/posix/tests/posix_getcwd_basic.phpt b/ext/posix/tests/posix_getcwd_basic.phpt new file mode 100644 index 0000000000..2477c376a8 --- /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_basic.phpt b/ext/posix/tests/posix_getgrgid_basic.phpt new file mode 100644 index 0000000000..866e11681a --- /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_getgrnam_basic.phpt b/ext/posix/tests/posix_getgrnam_basic.phpt new file mode 100644 index 0000000000..fd5bf23172 --- /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 0000000000..f062468b4f --- /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 0000000000..3195387b75 --- /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 0000000000..a737019a2f --- /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 0000000000..a1444413ed --- /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 0000000000..2da591c177 --- /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 0000000000..d675d6c182 --- /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 0000000000..1bcd59d0e6 --- /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 0000000000..7fdd0e7e4b --- /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_basic.phpt b/ext/posix/tests/posix_getsid_basic.phpt new file mode 100644 index 0000000000..a53e1df8b3 --- /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_initgroups_basic.phpt b/ext/posix/tests/posix_initgroups_basic.phpt new file mode 100644 index 0000000000..4a5005998e --- /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 0000000000..c995031af4 --- /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_mknod_basic.phpt b/ext/posix/tests/posix_mknod_basic.phpt new file mode 100644 index 0000000000..bc35156460 --- /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_strerror_error_basic.phpt b/ext/posix/tests/posix_strerror_error_basic.phpt new file mode 100644 index 0000000000..3359e0fe2a --- /dev/null +++ b/ext/posix/tests/posix_strerror_error_basic.phpt @@ -0,0 +1,46 @@ +--TEST-- +Test posix_strerror() function : error conditions +--SKIPIF-- +<?php + if (!extension_loaded('posix')) die('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) ); + +?> +===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%s" +===DONE====
\ No newline at end of file diff --git a/ext/posix/tests/posix_times_basic.phpt b/ext/posix/tests/posix_times_basic.phpt new file mode 100644 index 0000000000..eb8af10df4 --- /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_uname_basic.phpt b/ext/posix/tests/posix_uname_basic.phpt new file mode 100644 index 0000000000..7dd378192e --- /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 |