From: Christoph M. Becker Date: Thu, 2 Jul 2020 14:36:16 +0000 (+0200) Subject: Enable readlink_realpath_* tests on Windows X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f0b73345a2c128f5584d5998d1e012c85b28637;p=php Enable readlink_realpath_* tests on Windows We modify _basic1.phpt so it runs on Windows as well. The other test cases hit the issue that `readlink()` fails normally for regular files, but succeeds on Windows[1]. Therefore, we split these tests, but still fix the skip reasons. [1] --- diff --git a/ext/standard/tests/file/readlink_realpath_basic1.phpt b/ext/standard/tests/file/readlink_realpath_basic1.phpt index fa2056d076..867aef1eb5 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-- --FILE-- @@ -74,32 +75,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..f0072eec9b --- /dev/null +++ b/ext/standard/tests/file/readlink_realpath_basic2-win32.phpt @@ -0,0 +1,86 @@ +--TEST-- +Test readlink() and realpath functions: basic functionality - diff. path notation for files +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--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 104fba859d..9971fd6f95 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-- --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..679be4414c --- /dev/null +++ b/ext/standard/tests/file/readlink_realpath_error-win32.phpt @@ -0,0 +1,69 @@ +--TEST-- +Test readlink() and realpath() functions: error conditions +--SKIPIF-- + +--FILE-- + expected + +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 "*** Testing realpath(): error conditions ***\n"; +var_dump( realpath() ); // args < expected +var_dump( realpath(1, 2) ); // args > expected + +echo "\n*** Testing realpath() on a non-existent file ***\n"; +var_dump( realpath(__DIR__."/realpath_error.tmp") ); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing readlink(): error conditions *** + +Warning: readlink() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: readlink() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +*** 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(): error conditions *** + +Warning: realpath() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +Warning: realpath() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +*** 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 e2afb8bb36..82743b7300 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-- --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..b46944b23d --- /dev/null +++ b/ext/standard/tests/file/readlink_realpath_variation1-win32.phpt @@ -0,0 +1,98 @@ +--TEST-- +Test readlink() and realpath() functions: usage variation - linkname/filename stored in object(Bug #42038) +--SKIPIF-- + +--FILE-- +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-- + +--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 797badd914..1530029daa 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-- --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..7c75f09b03 --- /dev/null +++ b/ext/standard/tests/file/readlink_realpath_variation2-win32.phpt @@ -0,0 +1,105 @@ +--TEST-- +Test readlink() and realpath() functions: usage variation - linkname/filename stored in array(Bug #42038) +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--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 82deabecb6..fe0d1305c6 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-- --FILE--