wharmby         Mon Jun 15 12:14:57 2009 UTC

  Modified files:              
    /php-src/ext/posix/tests    posix_access_error_wrongparams.phpt 
                                posix_ttyname.phpt posix_getsid.phpt 
                                posix_getgrgid_macosx.phpt 
                                posix_ctermid.phpt 
                                posix_access_error_modes.phpt 
                                posix_getgrgid_wrongparams.phpt 
                                posix_times.phpt posix_uname.phpt 
                                posix_getgrgid.phpt 
                                posix_getsid_error.phpt 
                                posix_ttyname_error_wrongparams.phpt 
                                posix_access.phpt 
                                posix_mkfifo_wrongparams.phpt 
  Log:
  New POSIX extension tests from Berlin UG TestFest 2009.
  
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_access_error_wrongparams.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_access_error_wrongparams.phpt
diff -u /dev/null 
php-src/ext/posix/tests/posix_access_error_wrongparams.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_access_error_wrongparams.phpt Mon Jun 15 
12:14:56 2009
@@ -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, i...@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.');
+}
+?>
+--FILE--
+<?php
+
+var_dump( posix_access() );
+var_dump( posix_access(array()) );
+var_dump( posix_access(b'foo',array()) );
+var_dump( posix_access(null) );
+
+var_dump(posix_access('./foobar'));
+?>
+===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===
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_ttyname.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_ttyname.phpt
diff -u /dev/null php-src/ext/posix/tests/posix_ttyname.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_ttyname.phpt  Mon Jun 15 12:14:56 2009
@@ -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===
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_getsid.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_getsid.phpt
diff -u /dev/null php-src/ext/posix/tests/posix_getsid.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_getsid.phpt   Mon Jun 15 12:14:56 2009
@@ -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, i...@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===
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_getgrgid_macosx.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_getgrgid_macosx.phpt
diff -u /dev/null php-src/ext/posix/tests/posix_getgrgid_macosx.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_getgrgid_macosx.phpt  Mon Jun 15 12:14:56 2009
@@ -0,0 +1,23 @@
+--TEST--
+Test return values of posix_getgrgid() on MacOSX.
+--CREDITS--
+Till Klampaeckel, t...@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===
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_ctermid.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_ctermid.phpt
diff -u /dev/null php-src/ext/posix/tests/posix_ctermid.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_ctermid.phpt  Mon Jun 15 12:14:56 2009
@@ -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===
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_access_error_modes.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_access_error_modes.phpt
diff -u /dev/null php-src/ext/posix/tests/posix_access_error_modes.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_access_error_modes.phpt       Mon Jun 15 
12:14:56 2009
@@ -0,0 +1,42 @@
+--TEST--
+Test posix_access() function test error conditions
+--DESCRIPTION--
+checks if posix_access() failes for wrong permissions
+--CREDITS--
+Moritz Neuhaeuser, i...@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.');
+}
+?>
+--FILE--
+<?php
+$filename = dirname(__FILE__) . '/foo.test';
+var_dump(posix_access($filename, POSIX_F_OK));
+$fp = fopen($filename,"w");
+fwrite($fp,b"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--
+bool(false)
+bool(false)
+bool(false)
+bool(false)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_getgrgid_wrongparams.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_getgrgid_wrongparams.phpt
diff -u /dev/null php-src/ext/posix/tests/posix_getgrgid_wrongparams.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_getgrgid_wrongparams.phpt     Mon Jun 15 
12:14:56 2009
@@ -0,0 +1,28 @@
+--TEST--
+Test parameters on posix_getgrgid().
+--CREDITS--
+Till Klampaeckel, t...@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===
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_times.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_times.phpt
diff -u /dev/null php-src/ext/posix/tests/posix_times.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_times.phpt    Mon Jun 15 12:14:56 2009
@@ -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===
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_uname.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_uname.phpt
diff -u /dev/null php-src/ext/posix/tests/posix_uname.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_uname.phpt    Mon Jun 15 12:14:56 2009
@@ -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===
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_getgrgid.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_getgrgid.phpt
diff -u /dev/null php-src/ext/posix/tests/posix_getgrgid.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_getgrgid.phpt Mon Jun 15 12:14:56 2009
@@ -0,0 +1,45 @@
+--TEST--
+Test posix_getgrgid().
+--CREDITS--
+Till Klampaeckel, t...@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[b'name'])) {
+    die('Array index "name" does not exist.');
+}
+if (!isset($grp[b'passwd'])) {
+    die('Array index "passwd" does not exist.');
+}
+if (!isset($grp[b'members'])) {
+    die('Array index "members" does not exist.');
+} elseif (!is_array($grp[b'members'])) {
+    die('Array index "members" must be an array.');
+} else {
+    if (count($grp[b'members']) > 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===
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_getsid_error.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_getsid_error.phpt
diff -u /dev/null php-src/ext/posix/tests/posix_getsid_error.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_getsid_error.phpt     Mon Jun 15 12:14:56 2009
@@ -0,0 +1,28 @@
+--TEST--
+Test posix_getsid() function : error conditions 
+--DESCRIPTION--
+cases: no params, wrong param, wrong param range
+--CREDITS--
+Moritz Neuhaeuser, i...@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===
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_ttyname_error_wrongparams.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_ttyname_error_wrongparams.phpt
diff -u /dev/null 
php-src/ext/posix/tests/posix_ttyname_error_wrongparams.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_ttyname_error_wrongparams.phpt        Mon Jun 
15 12:14:56 2009
@@ -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===
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_access.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_access.phpt
diff -u /dev/null php-src/ext/posix/tests/posix_access.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_access.phpt   Mon Jun 15 12:14:57 2009
@@ -0,0 +1,48 @@
+--TEST--
+Test posix_access() function test
+--DESCRIPTION--
+checks for existence, read-access, write-access, execute-access
+--CREDITS--
+Moritz Neuhaeuser, i...@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.');
+}
+?>
+--FILE--
+<?php
+$filename = dirname(__FILE__) . '/foo.test';
+$fp = fopen($filename,"w");
+fwrite($fp, b"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--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/tests/posix_mkfifo_wrongparams.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/posix/tests/posix_mkfifo_wrongparams.phpt
diff -u /dev/null php-src/ext/posix/tests/posix_mkfifo_wrongparams.phpt:1.2
--- /dev/null   Mon Jun 15 12:14:57 2009
+++ php-src/ext/posix/tests/posix_mkfifo_wrongparams.phpt       Mon Jun 15 
12:14:57 2009
@@ -0,0 +1,21 @@
+--TEST--
+Test parameter validation in posix_mkfifo().
+--CREDITS--
+Till Klampaeckel, t...@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===

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to