diff options
| author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-07-02 18:29:39 +0200 |
|---|---|---|
| committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-07-02 18:31:43 +0200 |
| commit | e2be50001bae65e0bc9e696302245e2df4611eff (patch) | |
| tree | 9d89cbf6fbcd9633ef9826019abc02a3bdfcfd32 | |
| parent | 16cb88f31a3be8ea4e4de860d3be4bfe58b01889 (diff) | |
| parent | 6f0b73345a2c128f5584d5998d1e012c85b28637 (diff) | |
| download | php-git-e2be50001bae65e0bc9e696302245e2df4611eff.tar.gz | |
Merge branch 'PHP-7.4'
* PHP-7.4:
Enable readlink_realpath_* tests on Windows
9 files changed, 323 insertions, 15 deletions
diff --git a/ext/standard/tests/file/readlink_realpath_basic1.phpt b/ext/standard/tests/file/readlink_realpath_basic1.phpt index 2d9847ffb8..5adcbfbefd 100644 --- a/ext/standard/tests/file/readlink_realpath_basic1.phpt +++ b/ext/standard/tests/file/readlink_realpath_basic1.phpt @@ -2,8 +2,9 @@ Test readlink() and realpath functions: basic functionality - diff. path notation for links(Bug #42038) --SKIPIF-- <?php -if (substr(PHP_OS, 0, 3) == 'WIN') { - die('skip no symlinks on Windows'); +if (PHP_OS_FAMILY === 'Windows') { + include __DIR__ . '/windows_links/common.inc'; + skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__); } ?> --FILE-- @@ -67,32 +68,32 @@ rmdir("$name_prefix/"); *** Testing readlink() and realpath(): with valid and invalid path *** -- Iteration 1 -- -string(%d) "%s/readlink_realpath_basic1/home/readlink_realpath_basic1.tmp" -string(%d) "%s/readlink_realpath_basic1/home/readlink_realpath_basic1.tmp" +string(%d) "%s%ereadlink_realpath_basic1%ehome%ereadlink_realpath_basic1.tmp" +string(%d) "%s%ereadlink_realpath_basic1%ehome%ereadlink_realpath_basic1.tmp" -- Iteration 2 -- -string(%d) "%s/readlink_realpath_basic1/home/test/readlink_realpath_basic1.tmp" -string(%d) "%s/readlink_realpath_basic1/home/test/readlink_realpath_basic1.tmp" +string(%d) "%s%ereadlink_realpath_basic1%ehome%etest%ereadlink_realpath_basic1.tmp" +string(%d) "%s%ereadlink_realpath_basic1%ehome%etest%ereadlink_realpath_basic1.tmp" -- Iteration 3 -- -string(%d) "%s/readlink_realpath_basic1/home/test/readlink_realpath_basic1.tmp" -string(%d) "%s/readlink_realpath_basic1/home/test/readlink_realpath_basic1.tmp" +string(%d) "%s%ereadlink_realpath_basic1%ehome%etest%ereadlink_realpath_basic1.tmp" +string(%d) "%s%ereadlink_realpath_basic1%ehome%etest%ereadlink_realpath_basic1.tmp" -- Iteration 4 -- -Warning: readlink(): No such file or directory in %s on line %d +Warning: readlink(): %s in %s on line %d bool(false) bool(false) -- Iteration 5 -- -Warning: readlink(): No such file or directory in %s on line %d +Warning: readlink(): %s in %s on line %d bool(false) bool(false) -- Iteration 6 -- -Warning: readlink(): No such file or directory in %s on line %d +Warning: readlink(): %s in %s on line %d bool(false) %s diff --git a/ext/standard/tests/file/readlink_realpath_basic2-win32.phpt b/ext/standard/tests/file/readlink_realpath_basic2-win32.phpt new file mode 100644 index 0000000000..47023fc957 --- /dev/null +++ b/ext/standard/tests/file/readlink_realpath_basic2-win32.phpt @@ -0,0 +1,79 @@ +--TEST-- +Test readlink() and realpath functions: basic functionality - diff. path notation for files +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip only for Windows'); +} +?> +--FILE-- +<?php +/* creating directories, symbolic links and files */ +$file_path = __DIR__; +mkdir("$file_path/readlink_realpath_basic2/home/test/", 0777, true); + +$file_handle1 = fopen("$file_path/readlink_realpath_basic2/home/test/readlink_realpath_basic2.tmp", "w"); +$file_handle2 = fopen("$file_path/readlink_realpath_basic2/home/readlink_realpath_basic2.tmp", "w"); +$file_handle3 = fopen("$file_path/readlink_realpath_basic2/readlink_realpath_basic2.tmp", "w"); +fclose($file_handle1); +fclose($file_handle2); +fclose($file_handle3); + +echo "\n*** Testing realpath() on filenames ***\n"; +$filenames = array ( + /* filenames resulting in valid paths */ + "$file_path/readlink_realpath_basic2/home/readlink_realpath_basic2.tmp", + "$file_path/readlink_realpath_basic2/readlink_realpath_basic2.tmp", + "$file_path/readlink_realpath_basic2//home/test//../test/./readlink_realpath_basic2.tmp", + "$file_path/readlink_realpath_basic2/home//../././readlink_realpath_basic2.tmp", + + /* filenames with invalid path */ + "$file_path///readlink_realpath_basic2/home//..//././test//readlink_realpath_basic2.tmp", + "$file_path/readlink_realpath_basic2/home/../home/../test/../readlink_realpath_basic2.tmp", + "$file_path/readlink_realpath_basic2/readlink_realpath_basic2.tmp/" +); + +$counter = 1; +/* loop through $files to read the filepath of $file in the above array */ +foreach($filenames as $file) { + echo "\n-- Iteration $counter --\n"; + var_dump( realpath($file) ); + $counter++; +} + +echo "Done\n"; +?> +--CLEAN-- +<?php +$name_prefix = __DIR__."/readlink_realpath_basic2"; +unlink("$name_prefix/home/test/readlink_realpath_basic2.tmp"); +unlink("$name_prefix/home/readlink_realpath_basic2.tmp"); +unlink("$name_prefix/readlink_realpath_basic2.tmp"); +rmdir("$name_prefix/home/test/"); +rmdir("$name_prefix/home/"); +rmdir("$name_prefix/"); +?> +--EXPECTF-- +*** Testing realpath() on filenames *** + +-- Iteration 1 -- +string(%d) "%s%ereadlink_realpath_basic2%ehome%ereadlink_realpath_basic2.tmp" + +-- Iteration 2 -- +string(%d) "%s%ereadlink_realpath_basic2%ereadlink_realpath_basic2.tmp" + +-- Iteration 3 -- +string(%d) "%s%ereadlink_realpath_basic2%ehome%etest%ereadlink_realpath_basic2.tmp" + +-- Iteration 4 -- +string(%d) "%s%ereadlink_realpath_basic2%ereadlink_realpath_basic2.tmp" + +-- Iteration 5 -- +bool(false) + +-- Iteration 6 -- +string(%d) "%s%eext%estandard%etests%efile%ereadlink_realpath_basic2%ereadlink_realpath_basic2.tmp" + +-- Iteration 7 -- +%s +Done diff --git a/ext/standard/tests/file/readlink_realpath_basic2.phpt b/ext/standard/tests/file/readlink_realpath_basic2.phpt index c5cd985c5c..be73f43911 100644 --- a/ext/standard/tests/file/readlink_realpath_basic2.phpt +++ b/ext/standard/tests/file/readlink_realpath_basic2.phpt @@ -3,7 +3,7 @@ Test readlink() and realpath functions: basic functionality - diff. path notatio --SKIPIF-- <?php if (substr(PHP_OS, 0, 3) == 'WIN') { - die('skip no symlinks on Windows'); + die('skip not for Windows'); } ?> --FILE-- diff --git a/ext/standard/tests/file/readlink_realpath_error-win32.phpt b/ext/standard/tests/file/readlink_realpath_error-win32.phpt new file mode 100644 index 0000000000..c49beb2eda --- /dev/null +++ b/ext/standard/tests/file/readlink_realpath_error-win32.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test readlink() and realpath() functions: error conditions +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip only for Windows'); +} +?> +--FILE-- +<?php +echo "\n*** Testing readlink() on a non-existent link ***\n"; +var_dump( readlink(__DIR__."/readlink_error.tmp") ); + +echo "\n*** Testing readlink() on existing file ***\n"; +var_dump( readlink(__FILE__) ); + +echo "\n*** Testing readlink() on existing directory ***\n"; +var_dump( readlink(__DIR__) ); + +echo "\n*** Testing realpath() on a non-existent file ***\n"; +var_dump( realpath(__DIR__."/realpath_error.tmp") ); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing readlink() on a non-existent link *** + +Warning: readlink(): readlink failed to read the symbolic link (%s, error %d) in %s on line %d +bool(false) + +*** Testing readlink() on existing file *** +string(%d) "%s%eext%estandard%etests%efile%ereadlink_realpath_error-win32.php" + +*** Testing readlink() on existing directory *** +string(%d) "%s%eext%estandard%etests%efile" + +*** Testing realpath() on a non-existent file *** +%s +Done diff --git a/ext/standard/tests/file/readlink_realpath_error.phpt b/ext/standard/tests/file/readlink_realpath_error.phpt index d1aee746da..f595fb263d 100644 --- a/ext/standard/tests/file/readlink_realpath_error.phpt +++ b/ext/standard/tests/file/readlink_realpath_error.phpt @@ -3,7 +3,7 @@ Test readlink() and realpath() functions: error conditions --SKIPIF-- <?php if (substr(PHP_OS, 0, 3) == 'WIN') { - die('skip no symlinks on Windows'); + die('skip not for Windows'); } ?> --FILE-- diff --git a/ext/standard/tests/file/readlink_realpath_variation1-win32.phpt b/ext/standard/tests/file/readlink_realpath_variation1-win32.phpt new file mode 100644 index 0000000000..5c7448f6a8 --- /dev/null +++ b/ext/standard/tests/file/readlink_realpath_variation1-win32.phpt @@ -0,0 +1,91 @@ +--TEST-- +Test readlink() and realpath() functions: usage variation - linkname/filename stored in object(Bug #42038) +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip only for Windows'); +} else { + include __DIR__ . '/windows_links/common.inc'; + skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__); +} +?> +--FILE-- +<?php +echo "*** Testing readlink() and realpath() : usage variations ***\n"; +$name_prefix = __DIR__; +$filename = "$name_prefix/readlink_realpath_variation1/home/tests/link/readlink_realpath_variation1.tmp"; +mkdir("$name_prefix/readlink_realpath_variation1/home/tests/link/", 0777, true); + +echo "\n*** Testing readlink() and realpath() with linkname stored inside a object ***\n"; +// create a temp file +$file_handle = fopen($filename, "w"); +fclose($file_handle); + +// creating object with members as linkname +class object_temp { + public $linkname; + function __construct($link) { + $this->linkname = $link; + } +} +$obj1 = new object_temp("$name_prefix/readlink_realpath_variation1/../././readlink_realpath_variation1/home/readlink_realpath_variation1_link.tmp"); +$obj2 = new object_temp("$name_prefix/readlink_realpath_variation1/home/../..///readlink_realpath_variation1_link.tmp"); + +echo "\n-- Testing readlink() and realpath() with softlink, linkname stored inside an object --\n"; +// creating the links +var_dump( symlink($filename, $obj1->linkname) ); +var_dump( readlink($obj1->linkname) ); +var_dump( realpath($obj1->linkname) ); +var_dump( symlink($filename, $obj2->linkname) ); +var_dump( readlink($obj2->linkname) ); +var_dump( realpath($obj2->linkname) ); + +// deleting the link +unlink($obj1->linkname); +unlink($obj2->linkname); + +echo "\n-- Testing readlink() and realpath() with hardlink, linkname stored inside an object --\n"; +// creating hard links +var_dump( link($filename, $obj1->linkname) ); +var_dump( readlink($obj1->linkname) ); // invalid because readlink doesn't work with hardlink +var_dump( realpath($obj1->linkname) ); +var_dump( link($filename, $obj2->linkname) ); +var_dump( readlink($obj2->linkname) ); // invalid because readlink doesn't work with hardlink +var_dump( realpath($obj2->linkname) ); + +// delete the links +unlink($obj1->linkname); +unlink($obj2->linkname); + +echo "Done\n"; +?> +--CLEAN-- +<?php +$name_prefix = __DIR__."/readlink_realpath_variation1"; +unlink("$name_prefix/home/tests/link/readlink_realpath_variation1.tmp"); +rmdir("$name_prefix/home/tests/link/"); +rmdir("$name_prefix/home/tests/"); +rmdir("$name_prefix/home/"); +rmdir("$name_prefix/"); +?> +--EXPECTF-- +*** Testing readlink() and realpath() : usage variations *** + +*** Testing readlink() and realpath() with linkname stored inside a object *** + +-- Testing readlink() and realpath() with softlink, linkname stored inside an object -- +bool(true) +string(%d) "%s%ereadlink_realpath_variation1%ehome%etests%elink%ereadlink_realpath_variation1.tmp" +string(%d) "%s%ereadlink_realpath_variation1%ehome%etests%elink%ereadlink_realpath_variation1.tmp" +bool(true) +string(%d) "%s%ereadlink_realpath_variation1%ehome%etests%elink%ereadlink_realpath_variation1.tmp" +string(%d) "%s%ereadlink_realpath_variation1%ehome%etests%elink%ereadlink_realpath_variation1.tmp" + +-- Testing readlink() and realpath() with hardlink, linkname stored inside an object -- +bool(true) +string(%d) "%s%ereadlink_realpath_variation1%ehome%ereadlink_realpath_variation1_link.tmp" +string(%d) "%s%ereadlink_realpath_variation1%ehome%ereadlink_realpath_variation1_link.tmp" +bool(true) +string(%d) "%s%ereadlink_realpath_variation1_link.tmp" +string(%d) "%s%ereadlink_realpath_variation1_link.tmp" +Done diff --git a/ext/standard/tests/file/readlink_realpath_variation1.phpt b/ext/standard/tests/file/readlink_realpath_variation1.phpt index 77e4e933b5..1ddbedcf64 100644 --- a/ext/standard/tests/file/readlink_realpath_variation1.phpt +++ b/ext/standard/tests/file/readlink_realpath_variation1.phpt @@ -3,7 +3,7 @@ Test readlink() and realpath() functions: usage variation - linkname/filename st --SKIPIF-- <?php if (substr(PHP_OS, 0, 3) == 'WIN') { - die('skip no symlinks on Windows'); + die('skip not for Windows'); } ?> --FILE-- diff --git a/ext/standard/tests/file/readlink_realpath_variation2-win32.phpt b/ext/standard/tests/file/readlink_realpath_variation2-win32.phpt new file mode 100644 index 0000000000..aea1fd0cc0 --- /dev/null +++ b/ext/standard/tests/file/readlink_realpath_variation2-win32.phpt @@ -0,0 +1,98 @@ +--TEST-- +Test readlink() and realpath() functions: usage variation - linkname/filename stored in array(Bug #42038) +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip only for Windows'); +} else { + include __DIR__ . '/windows_links/common.inc'; + skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__); +} +?> +--FILE-- +<?php +echo "*** Testing readlink() and realpath() : usage variations ***\n"; +$name_prefix = __DIR__; +// create temp dir +mkdir("$name_prefix/readlink_realpath_variation2/home/tests/link/", 0777, true); +// create the file +$filename = "$name_prefix/readlink_realpath_variation2/home/tests/link/readlink_realpath_variation2.tmp"; +$fp = fopen($filename, "w"); +fclose($fp); + +echo "\n*** Testing readlink() and realpath() with linkname stored in an array ***\n"; +$link_arr = array ( + "$name_prefix////readlink_realpath_variation2/home/tests/link/readlink_realpath_variation2_link.tmp", + "$name_prefix/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/" +); + +echo "\n-- Testing readlink() and realpath() with softlink, linkname stored inside an array --\n"; +// creating the links +var_dump( symlink($filename, $link_arr[0]) ); +var_dump( readlink($link_arr[0]) ); +var_dump( realpath($link_arr[0]) ); +var_dump( symlink($filename, $link_arr[1]) ); +var_dump( readlink($link_arr[1]) ); +var_dump( realpath($link_arr[1]) ); + +// deleting the link +unlink($link_arr[0]); +unlink($link_arr[1]); + +echo "\n-- Testing readlink() and realpath() with hardlink, linkname stored inside an array --\n"; +// creating hard links +var_dump( link($filename, $link_arr[0]) ); +var_dump( readlink($link_arr[0]) ); // invalid because readlink doesn't work with hardlink +var_dump( realpath($link_arr[0]) ); +var_dump( link($filename, $link_arr[1]) ); +var_dump( readlink($link_arr[1]) ); // invalid because readlink doesn't work with hardlink +var_dump( realpath($link_arr[1]) ); + +// delete the links +unlink($link_arr[0]); +unlink($link_arr[1]); + +echo "Done\n"; +?> +--CLEAN-- +<?php +$name_prefix = __DIR__."/readlink_realpath_variation2"; +unlink("$name_prefix/home/tests/link/readlink_realpath_variation2.tmp"); +rmdir("$name_prefix/home/tests/link/"); +rmdir("$name_prefix/home/tests/"); +rmdir("$name_prefix/home/"); +rmdir("$name_prefix/"); +?> +--EXPECTF-- +*** Testing readlink() and realpath() : usage variations *** + +*** Testing readlink() and realpath() with linkname stored in an array *** + +-- Testing readlink() and realpath() with softlink, linkname stored inside an array -- +bool(true) +string(%d) "%s%ereadlink_realpath_variation2%ehome%etests%elink%ereadlink_realpath_variation2.tmp" +string(%d) "%s%ereadlink_realpath_variation2%ehome%etests%elink%ereadlink_realpath_variation2.tmp" + +Warning: symlink(): No such file or directory in %s on line %d +bool(false) + +Warning: readlink(): readlink failed to read the symbolic link (%s) in %s on line %d +bool(false) +bool(false) + +Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d + +-- Testing readlink() and realpath() with hardlink, linkname stored inside an array -- +bool(true) +string(%d) "%s%ereadlink_realpath_variation2%ehome%etests%elink%ereadlink_realpath_variation2_link.tmp" +string(%d) "%s%ereadlink_realpath_variation2%ehome%etests%elink%ereadlink_realpath_variation2_link.tmp" + +Warning: link(): No such file or directory in %s on line %d +bool(false) + +Warning: readlink(): readlink failed to read the symbolic link (%s) in %s on line %d +bool(false) +bool(false) + +Warning: unlink(%s/./readlink_realpath_variation2/home/../home//tests//..//..//..//home//readlink_realpath_variation2_link.tmp/): No such file or directory in %s on line %d +Done diff --git a/ext/standard/tests/file/readlink_realpath_variation2.phpt b/ext/standard/tests/file/readlink_realpath_variation2.phpt index 3738952fdd..e7d681036e 100644 --- a/ext/standard/tests/file/readlink_realpath_variation2.phpt +++ b/ext/standard/tests/file/readlink_realpath_variation2.phpt @@ -3,7 +3,7 @@ Test readlink() and realpath() functions: usage variation - linkname/filename st --SKIPIF-- <?php if (substr(PHP_OS, 0, 3) == 'WIN') { - die('skip no symlinks on Windows'); + die('skip not for Windows'); } ?> --FILE-- |
