cvs: php-src /ext/standard/tests/file 006_error.phpt filegroup_basic.phpt symlink_link_linkinfo_is_link_basic1.phpt
symlink_link_linkinfo_is_link_basic2.phpt symlink_link_linkinfo_is_link_error1.phpt symlink_link_linkinfo_is_link_error2.phpt
symlink_link_linkinfo_is_link_variation1.phpt symlink_link_linkinfo_is_link_variation2.phpt symlink_link_linkinfo_is_link_variation3.phpt
symlink_link_linkinfo_is_link_variation4.phpt symlink_link_linkinfo_is_link_variation5.phpt symlink_link_linkinfo_is_link_variation6.phpt
symlink_link_linkinfo_is_link_variation7.phpt symlink_link_linkinfo_is_link_variation8.phpt symlink_link_linkinfo_is_link_variation9.phpt

From: Date: Thu, 05 Jul 2007 18:59:20 +0000
Subject: cvs: php-src /ext/standard/tests/file 006_error.phpt filegroup_basic.phpt symlink_link_linkinfo_is_link_basic1.phpt
symlink_link_linkinfo_is_link_basic2.phpt symlink_link_linkinfo_is_link_error1.phpt symlink_link_linkinfo_is_link_error2.phpt
symlink_link_linkinfo_is_link_variation1.phpt symlink_link_linkinfo_is_link_variation2.phpt symlink_link_linkinfo_is_link_variation3.phpt
symlink_link_linkinfo_is_link_variation4.phpt symlink_link_linkinfo_is_link_variation5.phpt symlink_link_linkinfo_is_link_variation6.phpt
symlink_link_linkinfo_is_link_variation7.phpt symlink_link_linkinfo_is_link_variation8.phpt symlink_link_linkinfo_is_link_variation9.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-45101@lists.php.net to get a copy of this message
kraghuba Thu Jul 5 18:59:20 2007 UTC Modified files: /php-src/ext/standard/tests/file symlink_link_linkinfo_is_link_error1.phpt symlink_link_linkinfo_is_link_error2.phpt symlink_link_linkinfo_is_link_variation1.phpt symlink_link_linkinfo_is_link_variation2.phpt symlink_link_linkinfo_is_link_variation3.phpt symlink_link_linkinfo_is_link_variation4.phpt symlink_link_linkinfo_is_link_variation5.phpt symlink_link_linkinfo_is_link_basic1.phpt symlink_link_linkinfo_is_link_variation6.phpt symlink_link_linkinfo_is_link_basic2.phpt symlink_link_linkinfo_is_link_variation7.phpt symlink_link_linkinfo_is_link_variation8.phpt symlink_link_linkinfo_is_link_variation9.phpt filegroup_basic.phpt 006_error.phpt Log: fix test: 006_error.phpt & filegroup_basic.phpt fix and smaller tests for symlink_link_linkinfo_is_link[basic|error|variation].phpt

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt diff -u /dev/null php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt:1.2 --- /dev/null Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt Thu Jul 5 18:59:20 2007 @@ -0,0 +1,158 @@ +--TEST-- +Test symlink(), linkinfo(), link() and is_link() functions : error conditions - symlink & linkinfo +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +if (substr(PHP_OS, 0, 3) == 'SUN') { + die('skip Not valid for Sun Solaris'); +} +if (PHP_INT_SIZE != 4) { + die("skip this test is for 32bit platform only"); +} +?> +--FILE-- +<?php +/* Prototype: bool symlink ( string $target, string $link ); + Description: creates a symbolic link to the existing target with the specified name link + + Prototype: bool is_link ( string $filename ); + Description: Tells whether the given file is a symbolic link. + + Prototype: bool link ( string $target, string $link ); + Description: Create a hard link + + Prototype: int linkinfo ( string $path ); + Description: Gets information about a link +*/ + +// create temp $filename and create link $linkname to it +$filename = dirname(__FILE__)."/symlink_link_linkinfo_is_link_error1.tmp"; +$fp = fopen($filename, "w"); // create temp file +fclose($fp); + +// linkname used to create soft/hard link +$linkname = dirname(__FILE__)."/symlink_link_linkinfo_is_link_link_error1.tmp"; + +echo "*** Testing symlink() for error conditions ***\n"; +//zero arguments +var_dump( symlink() ); + +//more than expected +var_dump( symlink($filename, $linkname, true) ); + +//invalid arguments +var_dump( symlink(NULL, $linkname) ); // NULL as filename +var_dump( symlink('', $linkname) ); // empty string as filename +var_dump( symlink(false, $linkname) ); // boolean false as filename +var_dump( symlink($filename, NULL) ); // NULL as linkname +var_dump( symlink($filename, '') ); // '' as linkname +var_dump( symlink($filename, false) ); // false as linkname + +echo "\n*** Testing linkinfo() for error conditions ***\n"; +//zero arguments +var_dump( linkinfo() ); + +//more than expected +var_dump( linkinfo($linkname, true) ); + +//invalid arguments +var_dump( linkinfo(NULL) ); // NULL as linkname +var_dump( linkinfo('') ); // empty string as linkname +var_dump( linkinfo(false) ); // boolean false as linkname + +echo "Done\n"; +?> +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_error1.tmp"); +?> +--EXPECTF-- +*** Testing symlink() for error conditions *** + +Warning: symlink() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: symlink() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +Warning: symlink(): %s in %s on line %d +bool(false) + +Warning: symlink(): %s in %s on line %d +bool(false) + +Warning: symlink(): %s in %s on line %d +bool(false) + +Warning: symlink(): No such file or directory in %s on line %d +bool(false) + +Warning: symlink(): No such file or directory in %s on line %d +bool(false) + +Warning: symlink(): No such file or directory in %s on line %d +bool(false) + +*** Testing linkinfo() for error conditions *** + +Warning: linkinfo() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: linkinfo() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: linkinfo(): No such file or directory in %s on line %d +int(-1) + +Warning: linkinfo(): No such file or directory in %s on line %d +int(-1) + +Warning: linkinfo(): No such file or directory in %s on line %d +int(-1) +Done +--UEXPECTF-- +*** Testing symlink() for error conditions *** + +Warning: symlink() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: symlink() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +Warning: symlink(): %s in %s on line %d +bool(false) + +Warning: symlink(): %s in %s on line %d +bool(false) + +Warning: symlink(): %s in %s on line %d +bool(false) + +Warning: symlink(): No such file or directory in %s on line %d +bool(false) + +Warning: symlink(): No such file or directory in %s on line %d +bool(false) + +Warning: symlink(): No such file or directory in %s on line %d +bool(false) + +*** Testing linkinfo() for error conditions *** + +Warning: linkinfo() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: linkinfo() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +Warning: linkinfo(): No such file or directory in %s on line %d +int(-1) + +Warning: linkinfo(): No such file or directory in %s on line %d +int(-1) + +Warning: linkinfo(): No such file or directory in %s on line %d +int(-1) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt diff -u /dev/null php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt:1.2 --- /dev/null Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt Thu Jul 5 18:59:20 2007 @@ -0,0 +1,146 @@ +--TEST-- +Test symlink(), linkinfo(), link() and is_link() functions : error conditions - link & is_link +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +if (PHP_INT_SIZE != 4 ) { + die("skip this test is for 32bit platform only"); +} +?> +--FILE-- +<?php +/* Prototype: bool symlink ( string $target, string $link ); + Description: creates a symbolic link to the existing target with the specified name link + + Prototype: bool is_link ( string $filename ); + Description: Tells whether the given file is a symbolic link. + + Prototype: bool link ( string $target, string $link ); + Description: Create a hard link + + Prototype: int linkinfo ( string $path ); + Description: Gets information about a link +*/ + +// create temp $filename and create link $linkname to it +$filename = dirname(__FILE__)."/symlink_link_linkinfo_is_link_error2.tmp"; +$fp = fopen($filename, "w"); // create temp file +fclose($fp); + +// linkname used to create soft/hard link +$linkname = dirname(__FILE__)."/symlink_link_linkinfo_is_link_link_error2.tmp"; + +echo "*** Testing link() for error conditions ***\n"; +//zero arguments +var_dump( link() ); + +//more than expected +var_dump( link($filename, $linkname, false) ); + +//invalid arguments +var_dump( link(NULL, $linkname) ); // NULL as filename +var_dump( link('', $linkname) ); // empty string as filename +var_dump( link(false, $linkname) ); // boolean false as filename +var_dump( link($filename, NULL) ); // NULL as linkname +var_dump( link($filename, '') ); // '' as linkname +var_dump( link($filename, false) ); // false as linkname + +echo "\n*** Testing is_link() for error conditions ***\n"; +//zero arguments +var_dump( is_link() ); + +//more than expected +var_dump( is_link($linkname, "/") ); + +//invalid arguments +var_dump( is_link(NULL) ); // NULL as linkname +var_dump( is_link('') ); // empty string as linkname +var_dump( is_link(false) ); // boolean false as linkname +var_dump( is_link($filename) ); // file given to is_link + +echo "Done\n"; +?> +--CLEAN-- +<?php +unlink(dirname(__FILE__)."/symlink_link_linkinfo_is_link_error2.tmp"); +?> +--EXPECTF-- +*** Testing link() for error conditions *** + +Warning: link() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: link() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +*** Testing is_link() for error conditions *** + +Warning: is_link() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: is_link() expects exactly 1 parameter, 2 given in %s on line %d +NULL +bool(false) +bool(false) +bool(false) +bool(false) +Done +--UEXPECTF-- +*** Testing link() for error conditions *** + +Warning: link() expects exactly 2 parameters, 0 given in %s on line %d +NULL + +Warning: link() expects exactly 2 parameters, 3 given in %s on line %d +NULL + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +*** Testing is_link() for error conditions *** + +Warning: is_link() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: is_link() expects exactly 1 parameter, 2 given in %s on line %d +NULL +bool(false) +bool(false) +bool(false) +bool(false) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation1.phpt diff -u /dev/null php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation1.phpt:1.2 --- /dev/null Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation1.phpt Thu Jul 5 18:59:20 2007 @@ -0,0 +1,161 @@ +--TEST-- +Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link name stored in an array/object +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: bool symlink ( string $target, string $link ); + Description: creates a symbolic link to the existing target with the specified name link + + Prototype: bool is_link ( string $filename ); + Description: Tells whether the given file is a symbolic link. + + Prototype: bool link ( string $target, string $link ); + Description: Create a hard link + + Prototype: int linkinfo ( string $path ); + Description: Gets information about a link +*/ + +/* Variation 1 : Creating links across directories where linkname is stored as an object and array member */ + +// creating temp directory which will contain temp file and links created +$file_path = dirname(__FILE__); +$dirname = "$file_path/symlink_link_linkinfo_is_link_variation1/test/home"; +mkdir($dirname, 0777, true); + +// creating temp file; links are created to this file later on +$filename = "$file_path/symlink_link_linkinfo_is_link_variation1/symlink_link_linkinfo_is_link_variation1.tmp"; +$fp = fopen($filename, "w"); +fclose($fp); + +echo "*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members in an object ***\n"; +class object_temp { + var $linkname; + function object_temp($link) { + $this->linkname = $link; + } +} + +$obj = new object_temp("$dirname/symlink_link_linkinfo_is_link_link.tmp"); +/* Testing on soft links */ +echo "\n-- Working with soft links --\n"; +// creating soft link +var_dump( symlink($filename, $obj->linkname) ); +// check if the link exists +var_dump( linkinfo($obj->linkname) ); +// check if link is soft link +var_dump( is_link($obj->linkname) ); +// delete the link created +unlink($obj->linkname); +// clear the cache +clearstatcache(); + +/* Testing on hard links */ +echo "\n-- Working with hard links --\n"; +// creating hard link +var_dump( link($filename, $obj->linkname) ); +// check if the link exists +var_dump( linkinfo($obj->linkname) ); +// check if link is soft link; expected: false as the link is a hardlink +var_dump( is_link($obj->linkname) ); +// delete the link created +unlink($obj->linkname); +// clear the cache +clearstatcache(); + +echo "\n*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members of an array ***\n"; + +$link_arr = array("$dirname/symlink_link_linkinfo_is_link_link.tmp"); + +/* Testing on soft links */ +echo "\n-- Working with soft links --\n"; +// creating soft link +var_dump( symlink($filename, $link_arr[0]) ); +// check if the link exist +var_dump( linkinfo($link_arr[0]) ); +// check if link is soft link +var_dump( is_link($link_arr[0]) ); +// delete the link created +unlink($link_arr[0]); +// clear the cache +clearstatcache(); + +/* Testing on hard links */ +echo "\n-- Working with hard links --\n"; +// creating hard link +var_dump( link($filename, $link_arr[0]) ); +// check if the link exist +var_dump( linkinfo($link_arr[0]) ); +// check if link is soft link; expected: false as this is a hardlink +var_dump( is_link($link_arr[0]) ); +// delete the links created +unlink($link_arr[0]); +// clear the cache +clearstatcache(); + +echo "Done\n"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +$dirname = "$file_path/symlink_link_linkinfo_is_link_variation1"; +unlink("$dirname/symlink_link_linkinfo_is_link_variation1.tmp"); +rmdir("$dirname/test/home"); +rmdir("$dirname/test"); +rmdir($dirname); +?> +--EXPECTF-- +*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members in an object *** + +-- Working with soft links -- +bool(true) +int(%d) +bool(true) + +-- Working with hard links -- +bool(true) +int(%d) +bool(false) + +*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members of an array *** + +-- Working with soft links -- +bool(true) +int(%d) +bool(true) + +-- Working with hard links -- +bool(true) +int(%d) +bool(false) +Done +--UEXPECTF-- +*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members in an object *** + +-- Working with soft links -- +bool(true) +int(%d) +bool(true) + +-- Working with hard links -- +bool(true) +int(%d) +bool(false) + +*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members of an array *** + +-- Working with soft links -- +bool(true) +int(%d) +bool(true) + +-- Working with hard links -- +bool(true) +int(%d) +bool(false) +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation2.phpt diff -u /dev/null php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation2.phpt:1.2 --- /dev/null Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation2.phpt Thu Jul 5 18:59:20 2007 @@ -0,0 +1,61 @@ +--TEST-- +Test symlink(), linkinfo(), link() and is_link() functions : usage variations - hardlink to non-existent file +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: bool symlink ( string $target, string $link ); + Description: creates a symbolic link to the existing target with the specified name link + + Prototype: bool is_link ( string $filename ); + Description: Tells whether the given file is a symbolic link. + + Prototype: bool link ( string $target, string $link ); + Description: Create a hard link + + Prototype: int linkinfo ( string $path ); + Description: Gets information about a link +*/ + +/* Variation 2 : Create hard link to non-existent file */ + +$file_path = dirname(__FILE__); +// non-existing filename +$non_existent_file = "$file_path/non_existent_file_variation2.tmp"; +// non-existing linkname +$non_existent_linkname = "$file_path/non_existent_linkname_variation2.tmp"; + +echo "*** Creating a hard link to a non-existent file ***\n"; +// creating hard link to non_existent file +var_dump( link($non_existent_file, $non_existent_linkname) ); // expected false + +// checking linkinfo() and is_link() on the link; expected: false +var_dump( linkinfo($non_existent_linkname) ); +var_dump( is_link($non_existent_linkname) ); + +echo "Done\n"; +?> +--EXPECTF-- +*** Creating a hard link to a non-existent file *** + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: linkinfo(): No such file or directory in %s on line %d +int(-1) +bool(false) +Done +--UEXPECTF-- +*** Creating a hard link to a non-existent file *** + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: linkinfo(): No such file or directory in %s on line %d +int(-1) +bool(false) +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation3.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation3.phpt diff -u /dev/null php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation3.phpt:1.2 --- /dev/null Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation3.phpt Thu Jul 5 18:59:20 2007 @@ -0,0 +1,177 @@ +--TEST-- +Test symlink(), linkinfo(), link() and is_link() functions : usage variations - access/update file through softlink +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: bool symlink ( string $target, string $link ); + Description: creates a symbolic link to the existing target with the specified name link + + Prototype: bool is_link ( string $filename ); + Description: Tells whether the given file is a symbolic link. + + Prototype: bool link ( string $target, string $link ); + Description: Create a hard link + + Prototype: int linkinfo ( string $path ); + Description: Gets information about a link +*/ + +/* Variation 3 : Create file and a soft link to the file + Access data of the file through the soft link + Update the file through soft link + Check size of file and soft link link +*/ + +$file_path = dirname(__FILE__); +echo "*** Accessing and updating data of file through soft link ***\n"; +// Creating file and inserting data into it +$filename = "$file_path/symlink_link_linkinfo_is_link_variation3.tmp"; + +// create temp file +$file = fopen($filename, "w"); + +// create soft link to file +$linkname = "$file_path/symlink_link_linkinfo_is_link_link_variation3.tmp"; +var_dump( symlink($filename, $linkname) ); +// storing size of symlink in a local variable +$link_stat = lstat($linkname); // lstat of link +$link_size = $link_stat[7]; // size of soft link + +// fill data into file +fwrite($file, (binary)str_repeat("text", 20) ); +fclose($file); + +echo "\n-- Access data of the file through the soft link --\n"; +$data_from_link = file_get_contents($linkname); // data read from $filename +var_dump( $data_from_link ); + +echo "\n-- Check size of soft link and file --\n"; +var_dump( filesize($filename) ); +var_dump( filesize($linkname) ); + +// taking lstat of symlink +$stat = lstat($linkname); +// checking that size of symlink remains same +if ($link_size == $stat[7]) + echo "\nSoft link size remains same \n"; +else + echo "\nWarning: Soft link size has changed \n"; + +echo "\n-- Updating file with data through soft link --\n"; +// append link with data +$fp = fopen($linkname, "a"); // open in append mode +fwrite($fp, (binary)"Hello World"); +fclose($fp); + +// now check temp file for data; it should append "Hello World" +$data_from_file = file_get_contents($filename); +var_dump( $data_from_file ); + +echo "\n-- Check size of soft link and file --\n"; +var_dump( filesize($filename) ); +var_dump( filesize($linkname) ); + +// taking lstat of symlink +$stat = lstat($linkname); +// checking that size of symlink remains same +if ($link_size == $stat[7]) + echo "\nSoft link size remains same \n"; +else + echo "\nWarning: Soft link size has changed \n"; + +echo "\n-- Updating file with data and check data through soft link --\n"; +// write to temp file +$file = fopen($filename, "w"); +fwrite($file, (binary)"Hello World"); +fclose($file); + +// now check link for data; it should echo "Hello World" +$data_from_link = file_get_contents($linkname); +var_dump( $data_from_link ); + +echo "\n-- Check size of soft link and file --\n"; +var_dump( filesize($filename) ); +var_dump( filesize($linkname) ); + +// taking lstat of symlink +$stat = lstat($linkname); +// checking that size of symlink remains same +if ($link_size == $stat[7]) + echo "\nSoft link size remains same \n"; +else + echo "\nWarning: Soft link size has changed \n"; + +// delete the link +unlink($linkname); +// delete the temporary file +unlink($filename); + +echo "Done\n"; +?> +--EXPECTF-- +*** Accessing and updating data of file through soft link *** +bool(true) + +-- Access data of the file through the soft link -- +string(80) "texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext" + +-- Check size of soft link and file -- +int(80) +int(80) + +Soft link size remains same + +-- Updating file with data through soft link -- +string(91) "texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttextHello World" + +-- Check size of soft link and file -- +int(91) +int(91) + +Soft link size remains same + +-- Updating file with data and check data through soft link -- +string(11) "Hello World" + +-- Check size of soft link and file -- +int(11) +int(11) + +Soft link size remains same +Done +--UEXPECTF-- +*** Accessing and updating data of file through soft link *** +bool(true) + +-- Access data of the file through the soft link -- +string(80) "texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext" + +-- Check size of soft link and file -- +int(80) +int(80) + +Soft link size remains same + +-- Updating file with data through soft link -- +string(91) "texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttextHello World" + +-- Check size of soft link and file -- +int(91) +int(91) + +Soft link size remains same + +-- Updating file with data and check data through soft link -- +string(11) "Hello World" + +-- Check size of soft link and file -- +int(11) +int(11) + +Soft link size remains same +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation4.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation4.phpt diff -u /dev/null php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation4.phpt:1.2 --- /dev/null Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation4.phpt Thu Jul 5 18:59:20 2007 @@ -0,0 +1,147 @@ +--TEST-- +Test symlink(), linkinfo(), link() and is_link() functions : usage variations - access/update file through hard link +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: bool symlink ( string $target, string $link ); + Description: creates a symbolic link to the existing target with the specified name link + + Prototype: bool is_link ( string $filename ); + Description: Tells whether the given file is a symbolic link. + + Prototype: bool link ( string $target, string $link ); + Description: Create a hard link + + Prototype: int linkinfo ( string $path ); + Description: Gets information about a link +*/ + +/* Variation 4 : Create file and a hard link to the file + Access data of the file through the hard link + Update the file through hard link + Check size of file and hard link +*/ +$file_path = dirname(__FILE__); + +echo "*** Accessing and updating data of file through hard link ***\n"; +// Creating file and inserting data into it +$filename = "$file_path/symlink__link_linkinfo_is_link_variation4.tmp"; +// create temp file +$file = fopen($filename, "w"); +// fill data into file +fwrite($file, (binary)str_repeat("text", 20) ); +fclose($file); + +echo "\n-- Access data of the file through the hard link --\n"; +// create hard link to file +$linkname = "$file_path/symlink_link_linkinfo_is_link_link_variation4.tmp"; +var_dump( link($filename, $linkname) ); +$data_from_link = file_get_contents($linkname); // data read from $filename +var_dump( $data_from_link ); + +echo "\n-- Check size of hard link and file --\n"; +if( filesize($filename) == filesize($linkname) ) + echo "\nSize of file and hard link are same\n"; +else + echo "\nWarning: Size of file and hard link differ\n"; + +echo "\n-- Updating file with data through hard link --\n"; +// append link with data +$fp = fopen($linkname, "a"); // open in append mode +fwrite($fp, (binary)"Hello World"); +fclose($fp); + +// now check temp file for data; it should append "Hello World" +$data_from_file = file_get_contents($filename); +var_dump( $data_from_file ); + +echo "\n-- Check size of hard link and file --\n"; +if( filesize($filename) == filesize($linkname) ) + echo "\nSize of file and hard link are same\n"; +else + echo "\nWarning: Size of file and hard link differ\n"; + +echo "\n-- Updating file with data and check data through hard link --\n"; +// write to temp file +$file = fopen($filename, "w"); +fwrite($file, (binary)"Hello World"); +fclose($file); + +// now check link for data; it should echo "Hello World" +$data_from_link = file_get_contents($linkname); +var_dump( $data_from_link ); + +echo "\n-- Check size of hard link and file --\n"; +var_dump( filesize($filename) ); +var_dump( filesize($linkname) ); +if( filesize($filename) == filesize($linkname) ) + echo "\nSize of file and hard link are same\n"; +else + echo "\nWarning: Size of file and hard link differ\n"; + +// delete the link +unlink($linkname); +// delete the temporary file +unlink($filename); + +echo "Done\n"; +?> +--EXPECTF-- +*** Accessing and updating data of file through hard link *** + +-- Access data of the file through the hard link -- +bool(true) +string(80) "texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext" + +-- Check size of hard link and file -- + +Size of file and hard link are same + +-- Updating file with data through hard link -- +string(91) "texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttextHello World" + +-- Check size of hard link and file -- + +Size of file and hard link are same + +-- Updating file with data and check data through hard link -- +string(11) "Hello World" + +-- Check size of hard link and file -- +int(11) +int(11) + +Size of file and hard link are same +Done +--UEXPECTF-- +*** Accessing and updating data of file through hard link *** + +-- Access data of the file through the hard link -- +bool(true) +string(80) "texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext" + +-- Check size of hard link and file -- + +Size of file and hard link are same + +-- Updating file with data through hard link -- +string(91) "texttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttextHello World" + +-- Check size of hard link and file -- + +Size of file and hard link are same + +-- Updating file with data and check data through hard link -- +string(11) "Hello World" + +-- Check size of hard link and file -- +int(11) +int(11) + +Size of file and hard link are same +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation5.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation5.phpt diff -u /dev/null php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation5.phpt:1.2 --- /dev/null Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation5.phpt Thu Jul 5 18:59:20 2007 @@ -0,0 +1,84 @@ +--TEST-- +Test symlink(), linkinfo(), link() and is_link() functions : usage variations - work on deleted link +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: bool symlink ( string $target, string $link ); + Description: creates a symbolic link to the existing target with the specified name link + + Prototype: bool is_link ( string $filename ); + Description: Tells whether the given file is a symbolic link. + + Prototype: bool link ( string $target, string $link ); + Description: Create a hard link + + Prototype: int linkinfo ( string $path ); + Description: Gets information about a link +*/ + +/* Variation 5 : Creating link, deleting it and checking linkinfo(), is_link() on it */ + +$file_path = dirname(__FILE__); + +echo "*** Testing linkinfo() and is_link() on deleted link ***\n"; +// link name used here +$linkname = "$file_path/symlink_link_linkinfo_is_link_link_variation5.tmp"; + +// create temp dir +$dirname = "$file_path/symlink_link_linkinfo_is_link_variation5"; +mkdir($dirname); + +// filename used here +$filename = "$dirname/symlink_link_linkinfo_is_link_variation5.tmp"; +// create the file +$fp = fopen($filename, "w"); +$data = "Hello World"; +fwrite($fp, (binary)$data); +fclose($fp); + +var_dump( symlink($filename, $linkname) ); // create link + +// delete the link +var_dump( unlink($linkname) ); // delete the link + +// clear the cache +clearstatcache(); + +// try using linkinfo() & is_link() on deleted link; expected: false +$deleted_link = $linkname; +var_dump( linkinfo($deleted_link) ); +var_dump( is_link($deleted_link) ); + +echo "Done\n"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +$dirname = "$file_path/symlink_link_linkinfo_is_link_variation5"; +$filename = "$dirname/symlink_link_linkinfo_is_link_variation5.tmp"; +unlink($filename); +rmdir($dirname); +?> +--EXPECTF-- +*** Testing linkinfo() and is_link() on deleted link *** +bool(true) +bool(true) + +Warning: linkinfo(): No such file or directory in %s on line %d +int(-1) +bool(false) +Done +--UEXPECTF-- +*** Testing linkinfo() and is_link() on deleted link *** +bool(true) +bool(true) + +Warning: linkinfo(): No such file or directory in %s on line %d +int(-1) +bool(false) +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic1.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic1.phpt diff -u /dev/null php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic1.phpt:1.2 --- /dev/null Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic1.phpt Thu Jul 5 18:59:20 2007 @@ -0,0 +1,137 @@ +--TEST-- +Test symlink(), linkinfo(), link() and is_link() functions: basic functionality - link to files +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: bool symlink ( string $target, string $link ); + Description: creates a symbolic link to the existing target with the specified name link + + Prototype: bool is_link ( string $filename ); + Description: Tells whether the given file is a symbolic link. + + Prototype: bool link ( string $target, string $link ); + Description: Create a hard link + + Prototype: int linkinfo ( string $path ); + Description: Gets information about a link +*/ + +$file_path = dirname(__FILE__); + +// temp dir created in present working directory +$dirname = "symlink_link_linkinfo_is_link_basic1"; +mkdir("$file_path/$dirname"); // creating temp dir + +/* Creating soft/hard link to $filename created in temp directory $dirname + and checking linkinfo() and is_link() on the link created */ + +echo "*** Testing symlink(), linkinfo(), link() and is_link() : basic functionality ***\n"; + +// creating file in $dirname, links are created to the this file +$filename = "$file_path/$dirname/symlink_link_linkinfo_is_link_basic1.tmp"; +$filename = fopen($filename, "w"); +fclose($filename); + +// name of the soft link created to $filename +$sym_linkname = "$file_path/$dirname/symlink_link_linkinfo_is_link_softlink_basic1.tmp"; + +// name of the hard link created to $filename +$linkname = "$file_path/$dirname/symlink_link_linkinfo_is_link_hardlink_basic1.tmp"; + +// filename stored in array with single and double slash notation in its path +$files = array ( + "$file_path/$dirname/symlink_link_linkinfo_is_link_basic1.tmp", + "$file_path//$dirname//symlink_link_linkinfo_is_link_basic1.tmp" +); + +$counter = 1; +/* create soft/hard link to the file + and check linkinfo() and is_link() on the link created */ +foreach($files as $file) { + echo "\n-- Iteration $counter --\n"; + echo "-- Testing on soft links --\n"; + // create soft link + var_dump( symlink($file, $sym_linkname) ); + // checking information of link with linkinfo() + var_dump( linkinfo($sym_linkname) ); + // checking if given file is soft link + var_dump( is_link($sym_linkname) ); + // clear the cache + clearstatcache(); + + // testing on hard link + echo "-- Testing on hard links --\n"; + // creating hard link + var_dump( link($file, $linkname) ); + // checking information of link with linkinfo() + var_dump( linkinfo($linkname) ); + // checking if given link is soft link; expected: false + var_dump( is_link($linkname) ); + // clear the cache + clearstatcache(); + + // deleting the links + unlink($sym_linkname); + unlink($linkname); + $counter++; +} + +echo "Done\n"; +?> +--CLEAN-- +<?php +$dirname = dirname(__FILE__)."/symlink_link_linkinfo_is_link_basic1"; +unlink("$dirname/symlink_link_linkinfo_is_link_basic1.tmp"); +rmdir($dirname); +?> +--EXPECTF-- +*** Testing symlink(), linkinfo(), link() and is_link() : basic functionality *** + +-- Iteration 1 -- +-- Testing on soft links -- +bool(true) +int(%d) +bool(true) +-- Testing on hard links -- +bool(true) +int(%d) +bool(false) + +-- Iteration 2 -- +-- Testing on soft links -- +bool(true) +int(%d) +bool(true) +-- Testing on hard links -- +bool(true) +int(%d) +bool(false) +Done +--UEXPECTF-- +*** Testing symlink(), linkinfo(), link() and is_link() : basic functionality *** + +-- Iteration 1 -- +-- Testing on soft links -- +bool(true) +int(%d) +bool(true) +-- Testing on hard links -- +bool(true) +int(%d) +bool(false) + +-- Iteration 2 -- +-- Testing on soft links -- +bool(true) +int(%d) +bool(true) +-- Testing on hard links -- +bool(true) +int(%d) +bool(false) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt diff -u /dev/null php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt:1.2 --- /dev/null Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt Thu Jul 5 18:59:20 2007 @@ -0,0 +1,111 @@ +--TEST-- +Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link & dir perms. +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +if (substr(PHP_OS, 0, 3) == 'MAC') { + die('skip not valid for MacOS'); +} +?> +--FILE-- +<?php +/* Prototype: bool symlink ( string $target, string $link ); + Description: creates a symbolic link to the existing target with the specified name link + + Prototype: bool is_link ( string $filename ); + Description: Tells whether the given file is a symbolic link. + + Prototype: bool link ( string $target, string $link ); + Description: Create a hard link + + Prototype: int linkinfo ( string $path ); + Description: Gets information about a link +*/ + +/* Variation 6 : Change permission of directory and try creating links inside that directory */ +$file_path = dirname(__FILE__); + +echo "*** Creating links in a directory without permission to allow the operation ***\n"; +// temp file used +$dirname = "$file_path/symlink_link_linkinfo_is_link_variation6"; +mkdir($dirname); +$filename = "$dirname/symlink_link_linkinfo_is_link_variation6.tmp"; + +// remove all permissions from dir +var_dump( chmod($dirname, 0000) ); + +echo "\n-- Working with soft links --\n"; +$linkname = "$dirname/non_existent_link_variation5.tmp"; + +// expected: false +var_dump( symlink($filename, $linkname) ); // this link won't get created +var_dump( linkinfo($linkname) ); +var_dump( is_link($linkname) ); +// clear the cache +clearstatcache(); + +echo "\n-- Working with hard links --\n"; +// expected: false +var_dump( link($filename, $linkname) ); +var_dump( linkinfo($linkname) ); +var_dump( is_link($linkname) ); +// clear the cache +clearstatcache(); + +chmod($dirname, 0777); // to enable dir deletion +echo "Done\n"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +$dirname = "$file_path/symlink_link_linkinfo_is_link_variation6"; +$filename = "$dirname/symlink_link_linkinfo_is_link_variation6.tmp"; +unlink($filename); +rmdir($dirname); +?> +--EXPECTF-- +*** Creating links in a directory without permission to allow the operation *** +bool(true) + +-- Working with soft links -- + +Warning: symlink(): Permission denied in %s on line %d +bool(false) + +Warning: linkinfo(): Permission denied in %s on line %d +int(-1) +bool(false) + +-- Working with hard links -- + +Warning: link(): Permission denied in %s on line %d +bool(false) + +Warning: linkinfo(): Permission denied in %s on line %d +int(-1) +bool(false) +Done +--UEXPECTF-- +*** Creating links in a directory without permission to allow the operation *** +bool(true) + +-- Working with soft links -- + +Warning: symlink(): Permission denied in %s on line %d +bool(false) + +Warning: linkinfo(): Permission denied in %s on line %d +int(-1) +bool(false) + +-- Working with hard links -- + +Warning: link(): Permission denied in %s on line %d +bool(false) + +Warning: linkinfo(): Permission denied in %s on line %d +int(-1) +bool(false) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic2.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic2.phpt diff -u /dev/null php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic2.phpt:1.2 --- /dev/null Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_basic2.phpt Thu Jul 5 18:59:20 2007 @@ -0,0 +1,110 @@ +--TEST-- +Test symlink(), linkinfo(), link() and is_link() functions: basic functionality - link to dirs +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: bool symlink ( string $target, string $link ); + Description: creates a symbolic link to the existing target with the specified name link + + Prototype: bool is_link ( string $filename ); + Description: Tells whether the given file is a symbolic link. + + Prototype: bool link ( string $target, string $link ); + Description: Create a hard link + + Prototype: int linkinfo ( string $path ); + Description: Gets information about a link +*/ + +$file_path = dirname(__FILE__); + +echo "*** Testing symlink(), linkinfo(), link() and is_link() : basic functionality ***\n"; + +/* Creating soft/hard link to the temporary dir $dirname and checking + linkinfo() and is_link() on the link created to $dirname */ + +$dirname = "symlink_link_linkinfo_is_link_basic2"; +mkdir($file_path."/".$dirname); + +echo "\n*** Testing symlink(), linkinfo(), link() and is_link() on directory ***\n"; + +// name of the soft link created to $dirname +$sym_linkname = "$file_path/$dirname/symlink_link_linkinfo_is_link_softlink_basic2.tmp"; + +// name of the hard link created to $dirname +$linkname = "$file_path/$dirname/symlink_link_linkinfo_is_link_hardlink_basic2.tmp"; + +// testing on soft link +echo "\n-- Testing on soft links --\n"; +// creating soft link to $dirname +var_dump( symlink("$file_path/$dirname", $sym_linkname) ); // this works, expected true +// gets information about soft link created to directory; expected: true +var_dump( linkinfo($sym_linkname) ); +// checks if link created is soft link; expected: true +var_dump( is_link($sym_linkname) ); +// clear the cache +clearstatcache(); + +// testing on hard link +echo "\n-- Testing on hard links --\n"; +// creating hard link to $dirname; expected: false +var_dump( link("$file_path/$dirname", $linkname) ); // this doesn't work, expected false +var_dump( linkinfo($linkname) ); // link doesn't exists as not created, expected false +var_dump( is_link($linkname) ); // link doesn't exists as not created, expected false +// clear the cache +clearstatcache(); + +// deleting the links +unlink($sym_linkname); + +echo "Done\n"; +?> +--CLEAN-- +<?php +$dirname = dirname(__FILE__)."/symlink_link_linkinfo_is_link_basic2"; +unlink("$dirname/symlink_link_linkinfo_is_link_basic2.tmp"); +rmdir($dirname); +?> +--EXPECTF-- +*** Testing symlink(), linkinfo(), link() and is_link() : basic functionality *** + +*** Testing symlink(), linkinfo(), link() and is_link() on directory *** + +-- Testing on soft links -- +bool(true) +int(%d) +bool(true) + +-- Testing on hard links -- + +Warning: link(): %s in %s on line %d +bool(false) + +Warning: linkinfo(): No such file or directory in %s on line %d +int(-1) +bool(false) +Done +--UEXPECTF-- +*** Testing symlink(), linkinfo(), link() and is_link() : basic functionality *** + +*** Testing symlink(), linkinfo(), link() and is_link() on directory *** + +-- Testing on soft links -- +bool(true) +int(%d) +bool(true) + +-- Testing on hard links -- + +Warning: link(): %s in %s on line %d +bool(false) + +Warning: linkinfo(): No such file or directory in %s on line %d +int(-1) +bool(false) +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation7.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation7.phpt diff -u /dev/null php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation7.phpt:1.2 --- /dev/null Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation7.phpt Thu Jul 5 18:59:20 2007 @@ -0,0 +1,113 @@ +--TEST-- +Test symlink(), linkinfo(), link() and is_link() functions : usage variations - try link to self +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: bool symlink ( string $target, string $link ); + Description: creates a symbolic link to the existing target with the specified name link + + Prototype: bool is_link ( string $filename ); + Description: Tells whether the given file is a symbolic link. + + Prototype: bool link ( string $target, string $link ); + Description: Create a hard link + + Prototype: int linkinfo ( string $path ); + Description: Gets information about a link +*/ + +/* Variation 7 : Create soft/hard link to itself */ + +// temp file used +$file_path = dirname(__FILE__); +$dir = "$file_path/symlink_link_linkinfo_is_link_variation7"; +$filename = "$dir/symlink_link_linkinfo_is_link_variation7.tmp"; +// link name used +$linkname = "$dir/symlink_link_linkinfo_is_link_link_variation7.tmp"; +// temp dirname used +$dirname = "$dir/home/test"; +mkdir($dirname, 0755, true); + +// create file +$fp = fopen($filename, "w"); +fclose($fp); + +echo "*** Create soft link to file and then to itself ***\n"; +// create soft link to $filename +var_dump( symlink($filename, $linkname) ); +// create another link to $linkname +var_dump( symlink($linkname, $linkname) ); +// delete link +unlink($linkname); + +echo "\n*** Create soft link to directory and then to itself ***\n"; +// create soft link to $dirname +var_dump( symlink($dirname, $linkname) ); +// create another link to $dirname +var_dump( symlink($linkname, $linkname) ); +// delete link +unlink($linkname); + +echo "\n*** Create hard link to file and then to itself ***\n"; +// create hard link to $filename +var_dump( link($filename, $linkname) ); +// create another link to $linkname +var_dump( link($linkname, $linkname) ); +// delete link +unlink($linkname); + +echo "Done\n"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +$dir = "$file_path/symlink_link_linkinfo_is_link_variation7"; +$filename = "$dir/symlink_link_linkinfo_is_link_variation7.tmp"; +unlink($filename); +rmdir("$dir/home/test"); +rmdir("$dir/home"); +rmdir($dir); +?> +--EXPECTF-- +*** Create soft link to file and then to itself *** +bool(true) + +Warning: symlink(): File exists in %s on line %d +bool(false) + +*** Create soft link to directory and then to itself *** +bool(true) + +Warning: symlink(): File exists in %s on line %d +bool(false) + +*** Create hard link to file and then to itself *** +bool(true) + +Warning: link(): File exists in %s on line %d +bool(false) +Done +--UEXPECTF-- +*** Create soft link to file and then to itself *** +bool(true) + +Warning: symlink(): File exists in %s on line %d +bool(false) + +*** Create soft link to directory and then to itself *** +bool(true) + +Warning: symlink(): File exists in %s on line %d +bool(false) + +*** Create hard link to file and then to itself *** +bool(true) + +Warning: link(): File exists in %s on line %d +bool(false) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation8.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation8.phpt diff -u /dev/null php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation8.phpt:1.2 --- /dev/null Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation8.phpt Thu Jul 5 18:59:20 2007 @@ -0,0 +1,96 @@ +--TEST-- +Test symlink(), linkinfo(), link() and is_link() functions : usage variations - try link with same name in diff. dir +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: bool symlink ( string $target, string $link ); + Description: creates a symbolic link to the existing target with the specified name link + + Prototype: bool is_link ( string $filename ); + Description: Tells whether the given file is a symbolic link. + + Prototype: bool link ( string $target, string $link ); + Description: Create a hard link + + Prototype: int linkinfo ( string $path ); + Description: Gets information about a link +*/ + +/* Variation 8 : Create soft/hard link to different directory */ + +/* creating link to a file in different dir with the same name as the file */ +echo "\n*** Create hard link in different directory with same filename ***\n"; +// temp file used +$file_path = dirname(__FILE__); +$filename = "$file_path/symlink_link_linkinfo_is_link_variation8.tmp"; +// temp link name used +$dirname = "$file_path/symlink_link_linkinfo_is_link1_variation8"; +mkdir($dirname); +$linkname = "symlink_link_linkinfo_is_link_variation8.tmp"; +// create temp file +$fp = fopen($filename, "w"); +fclose($fp); + +var_dump( link($filename, $dirname."/") ); // this fails indicating file exists +// ok, creates "$file_path/symlink_link_linkinfo_is_link1_variation8/symlink_link_linkinfo_is_link_variation8.tmp" link +var_dump( link($filename, $dirname."/".$linkname) ); // this works fine +// delete link +unlink($dirname."/".$linkname); +// delete temp file +unlink($filename); +// delete temp dir +rmdir($dirname); + +echo "\n*** Create soft link in different directory with same filename ***\n"; +$filename = "$file_path/symlink_link_linkinfo_is_link_variation8.tmp"; +// temp link name used +$dirname = "$file_path/symlink_link_linkinfo_is_link1_variation8"; +mkdir($dirname); +$linkname = "symlink_link_linkinfo_is_link_variation8.tmp"; +// create temp file +$fp = fopen($filename, "w"); +fclose($fp); + +var_dump( symlink($filename, $dirname."/") ); // this fails indicating file exists +// ok, creates "$file_path/symlink_link_linkinfo_is_link1_variation8/symlink_link_linkinfo_is_link_variation8.tmp" link +var_dump( symlink($filename, $dirname."/".$linkname) ); // this works fine +// delete link +unlink($dirname."/".$linkname); +// delete temp file +unlink($filename); +// delete temp dir +rmdir($dirname); + +echo "Done\n"; +?> +--EXPECTF-- +*** Create hard link in different directory with same filename *** + +Warning: link(): File exists in %s on line %d +bool(false) +bool(true) + +*** Create soft link in different directory with same filename *** + +Warning: symlink(): File exists in %s on line %d +bool(false) +bool(true) +Done +--UEXPECTF-- +*** Create hard link in different directory with same filename *** + +Warning: link(): File exists in %s on line %d +bool(false) +bool(true) + +*** Create soft link in different directory with same filename *** + +Warning: symlink(): File exists in %s on line %d +bool(false) +bool(true) +Done http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation9.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation9.phpt diff -u /dev/null php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation9.phpt:1.2 --- /dev/null Thu Jul 5 18:59:20 2007 +++ php-src/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation9.phpt Thu Jul 5 18:59:20 2007 @@ -0,0 +1,143 @@ +--TEST-- +Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link & lstat[dev] value +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip no symlinks on Windows'); +} +?> +--FILE-- +<?php +/* Prototype: bool symlink ( string $target, string $link ); + Description: creates a symbolic link to the existing target with the specified name link + + Prototype: bool is_link ( string $filename ); + Description: Tells whether the given file is a symbolic link. + + Prototype: bool link ( string $target, string $link ); + Description: Create a hard link + + Prototype: int linkinfo ( string $path ); + Description: Gets information about a link +*/ + +/* Variation 9 : Check lstat of soft/hard link created + Check linkinfo() value with lstat['dev'] +*/ +// temp file used +$file_path = dirname(__FILE__); +$dirname = $file_path."/symlink_link_linkinfo_is_link_variation9"; +mkdir($dirname); +$filename = "$dirname/symlink_link_linkinfo_is_link_variation9.tmp"; +// soft link name used +$soft_link = "$dirname/symlink_link_linkinfo_is_link_softlink_variation9.tmp"; +// hard link name used +$hard_link = "$dirname/symlink_link_linkinfo_is_link_hardlink_variation9.tmp"; + +// create the file +$fp = fopen($filename, "w"); +fclose($fp); + +echo "*** Checking lstat() on soft link ***\n"; +// create soft link +var_dump( symlink($filename, $soft_link) ); + +// confirming that linkinfo() = lstat['dev'] , this should always match +$linkinfo = linkinfo($soft_link); +$s1 = lstat($soft_link); +echo "linkinfo() returns : $linkinfo\n"; +echo "lstat() returns lstat['dev'] as $s1[0]\n"; +if( $s1[0] == $linkinfo ) + echo "\nlinkinfo() value matches lstat['dev']\n"; +else + echo "\nWarning: linkinfo() value doesnt match lstat['dev']\n"; +// delete link +unlink($soft_link); + +echo "\n*** Checking lstat() on hard link ***\n"; +// create hard link +var_dump( link($filename, $hard_link) ); +// confirming that linkinfo() = lstat['dev'] , this should always match +$linkinfo = linkinfo($hard_link); +$s1 = lstat($hard_link); +echo "linkinfo() returns : $linkinfo\n"; +echo "lstat() returns lstat['dev'] as $s1[0]\n"; +if( $s1[0] == $linkinfo ) + echo "\nlinkinfo() value matches lstat['dev']\n"; +else + echo "\nWarning: linkinfo() value doesnt match lstat['dev']\n"; + +// delete link +unlink($hard_link); + +echo "\n*** Checking lstat() on a soft link to directory ***\n"; +// create soft link +var_dump( symlink($dirname, $soft_link) ); + +// confirming that linkinfo() = lstat['dev'], this should always match +$linkinfo = linkinfo($soft_link); +$s1 = lstat($soft_link); +echo "linkinfo() returns : $linkinfo\n"; +echo "lstat() returns lstat['dev'] as $s1[0]\n"; +if( $s1[0] == $linkinfo ) + echo "\nlinkinfo() value matches lstat['dev']\n"; +else + echo "\nWarning: linkinfo() value doesnt match lstat['dev']\n"; + +// delete link +unlink($soft_link); + +echo "Done\n"; +?> +--CLEAN-- +<?php +$file_path = dirname(__FILE__); +$dirname = $file_path."/symlink_link_linkinfo_is_link_variation9"; +$filename = "$dirname/symlink_link_linkinfo_is_link_variation9.tmp"; +unlink($filename); +rmdir($dirname); +?> +--EXPECTF-- +*** Checking lstat() on soft link *** +bool(true) +linkinfo() returns : %d +lstat() returns lstat['dev'] as %d + +linkinfo() value matches lstat['dev'] + +*** Checking lstat() on hard link *** +bool(true) +linkinfo() returns : %d +lstat() returns lstat['dev'] as %d + +linkinfo() value matches lstat['dev'] + +*** Checking lstat() on a soft link to directory *** +bool(true) +linkinfo() returns : %d +lstat() returns lstat['dev'] as %d + +linkinfo() value matches lstat['dev'] +Done +--UEXPECTF-- +*** Checking lstat() on soft link *** +bool(true) +linkinfo() returns : %d +lstat() returns lstat['dev'] as %d + +linkinfo() value matches lstat['dev'] + +*** Checking lstat() on hard link *** +bool(true) +linkinfo() returns : %d +lstat() returns lstat['dev'] as %d + +linkinfo() value matches lstat['dev'] + +*** Checking lstat() on a soft link to directory *** +bool(true) +linkinfo() returns : %d +lstat() returns lstat['dev'] as %d + +linkinfo() value matches lstat['dev'] +Done \ No newline at end of file http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/filegroup_basic.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/standard/tests/file/filegroup_basic.phpt diff -u php-src/ext/standard/tests/file/filegroup_basic.phpt:1.2 php-src/ext/standard/tests/file/filegroup_basic.phpt:1.3 --- php-src/ext/standard/tests/file/filegroup_basic.phpt:1.2 Wed Jun 13 22:46:37 2007 +++ php-src/ext/standard/tests/file/filegroup_basic.phpt Thu Jul 5 18:59:20 2007 @@ -2,8 +2,8 @@ Test filegroup() function: basic functionality --SKIPIF-- <?php -if (!function_exists("posix_getgrgid")) { - die("skip no posix_getgrgid"); +if( substr(PHP_OS, 0, 3) == 'WIN') { + die('skip Not valid for Windows'); } ?> --FILE-- @@ -17,7 +17,7 @@ echo "-- Testing with the file or directory created by owner --\n"; $file_path = dirname(__FILE__); -var_dump( posix_getgrgid( filegroup(__FILE__) ) ); +var_dump( filegroup(__FILE__) ); var_dump( filegroup(".") ); var_dump( filegroup("./..") ); @@ -55,42 +55,22 @@ --EXPECTF-- *** Testing filegroup(): basic functionality *** -- Testing with the file or directory created by owner -- -array(4) { - ["name"]=> - string(%d) "%s" - ["passwd"]=> - string(1) "x" - ["members"]=> - array(0) { - } - ["gid"]=> - int(%d) -} +int(%d) int(%d) int(%d) int(%d) int(%d) -- Testing with the standard file or directory -- -int(0) -int(0) -int(0) +int(%d) +int(%d) +int(%d) *** Done *** --UEXPECTF-- *** Testing filegroup(): basic functionality *** -- Testing with the file or directory created by owner -- -array(4) { - ["name"]=> - string(%d) "%s" - ["passwd"]=> - string(1) "x" - ["members"]=> - array(0) { - } - ["gid"]=> - int(%d) -} +int(%d) int(%d) int(%d) @@ -99,8 +79,8 @@ int(%d) -- Testing with the standard file or directory -- -int(0) -int(0) -int(0) +int(%d) +int(%d) +int(%d) *** Done *** http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/006_error.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/standard/tests/file/006_error.phpt diff -u php-src/ext/standard/tests/file/006_error.phpt:1.2 php-src/ext/standard/tests/file/006_error.phpt:1.3 --- php-src/ext/standard/tests/file/006_error.phpt:1.2 Mon Jun 11 16:40:27 2007 +++ php-src/ext/standard/tests/file/006_error.phpt Thu Jul 5 18:59:20 2007 @@ -5,9 +5,17 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { die('skip Not on Windows'); } -elseif (get_current_user() == 'root') { - die( "skip Do not run with root permissions" ); +// Skip if being run by root +$filename = dirname(__FILE__)."/006_root_check.tmp"; +$fp = fopen($filename, 'w'); +fclose($fp); +if(fileowner($filename) == 0) { + unlink ($filename); + die('skip...cannot be run as root\n'); } + +unlink($filename); + ?> --FILE-- <?php @@ -60,11 +68,11 @@ --EXPECTF-- *** Testing error conditions for fileperms(), chmod() *** -Warning: chmod(): Operation not permitted in %s on line %d +Warning: chmod(): %s in %s on line %d bool(false) 100644 -Warning: chmod(): Operation not permitted in %s on line %d +Warning: chmod(): %s in %s on line %d bool(false) 40755 @@ -100,11 +108,11 @@ --UEXPECTF-- *** Testing error conditions for fileperms(), chmod() *** -Warning: chmod(): Operation not permitted in %s on line %d +Warning: chmod(): %s in %s on line %d bool(false) 100644 -Warning: chmod(): Operation not permitted in %s on line %d +Warning: chmod(): %s in %s on line %d bool(false) 40755
« previous php.cvs (#45101) next »