Browse Source

New POISX tests. Tested on Windows (all test SKIP), Linux and Linux 64

PHP-5.2.1RC1
andy wharmby 17 years ago
parent
commit
32c8f50ea9
  1. 22
      ext/posix/tests/posix_getcwd_basic.phpt
  2. 30
      ext/posix/tests/posix_getgrgid_basic.phpt
  3. 23
      ext/posix/tests/posix_getgrnam_basic.phpt
  4. 24
      ext/posix/tests/posix_getgroups_basic.phpt
  5. 23
      ext/posix/tests/posix_getpgid_basic.phpt
  6. 21
      ext/posix/tests/posix_getpgrp_basic.phpt
  7. 21
      ext/posix/tests/posix_getpid_basic.phpt
  8. 21
      ext/posix/tests/posix_getppid_basic.phpt
  9. 23
      ext/posix/tests/posix_getpwnam_basic.phpt
  10. 30
      ext/posix/tests/posix_getpwuid_basic.phpt
  11. 20
      ext/posix/tests/posix_getrlimit_basic.phpt
  12. 22
      ext/posix/tests/posix_getsid_basic.phpt
  13. 22
      ext/posix/tests/posix_initgroups_basic.phpt
  14. 39
      ext/posix/tests/posix_kill_basic.phpt
  15. 18
      ext/posix/tests/posix_mknod_basic.phpt
  16. 46
      ext/posix/tests/posix_strerror_error_basic.phpt
  17. 37
      ext/posix/tests/posix_times_basic.phpt
  18. 28
      ext/posix/tests/posix_uname_basic.phpt

22
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: Wrong parameter count for posix_getcwd() in %s on line %d
NULL
===DONE===

30
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===

23
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===

24
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===

23
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====

21
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====

21
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====

21
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====

23
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====

30
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====

20
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====

22
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====

22
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====

39
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====

18
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====

46
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====

37
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====

28
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====
Loading…
Cancel
Save