]> granicus.if.org Git - php/commitdiff
New POISX tests. Tested on Windows (all test SKIP), Linux and Linux 64
authorandy wharmby <wharmby@php.net>
Thu, 11 Jun 2009 12:30:57 +0000 (12:30 +0000)
committerandy wharmby <wharmby@php.net>
Thu, 11 Jun 2009 12:30:57 +0000 (12:30 +0000)
18 files changed:
ext/posix/tests/posix_getcwd_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_getgrgid_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_getgrnam_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_getgroups_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_getpgid_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_getpgrp_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_getpid_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_getppid_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_getpwnam_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_getpwuid_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_getrlimit_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_getsid_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_initgroups_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_kill_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_mknod_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_strerror_error_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_times_basic.phpt [new file with mode: 0644]
ext/posix/tests/posix_uname_basic.phpt [new file with mode: 0644]

diff --git a/ext/posix/tests/posix_getcwd_basic.phpt b/ext/posix/tests/posix_getcwd_basic.phpt
new file mode 100644 (file)
index 0000000..6dbed50
--- /dev/null
@@ -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===
diff --git a/ext/posix/tests/posix_getgrgid_basic.phpt b/ext/posix/tests/posix_getgrgid_basic.phpt
new file mode 100644 (file)
index 0000000..866e116
--- /dev/null
@@ -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 (file)
index 0000000..fd5bf23
--- /dev/null
@@ -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 (file)
index 0000000..f062468
--- /dev/null
@@ -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 (file)
index 0000000..3195387
--- /dev/null
@@ -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 (file)
index 0000000..a737019
--- /dev/null
@@ -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 (file)
index 0000000..a144441
--- /dev/null
@@ -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 (file)
index 0000000..2da591c
--- /dev/null
@@ -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 (file)
index 0000000..d675d6c
--- /dev/null
@@ -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 (file)
index 0000000..1bcd59d
--- /dev/null
@@ -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 (file)
index 0000000..7fdd0e7
--- /dev/null
@@ -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 (file)
index 0000000..a53e1df
--- /dev/null
@@ -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 (file)
index 0000000..4a50059
--- /dev/null
@@ -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 (file)
index 0000000..c995031
--- /dev/null
@@ -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 (file)
index 0000000..bc35156
--- /dev/null
@@ -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 (file)
index 0000000..3359e0f
--- /dev/null
@@ -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 (file)
index 0000000..eb8af10
--- /dev/null
@@ -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 (file)
index 0000000..7dd3781
--- /dev/null
@@ -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