mirror of
https://github.com/php/php-src.git
synced 2026-04-15 03:51:07 +02:00
Enable symlink_link_linkinfo_is_link_* tests on Windows
We mark symlink_link_linkinfo_is_link_error2.phpt as XFAIL on Windows
ZTS. Several Windows API file system functions ignore trailing spaces
in absolute filenames after the final directory separator, which causes
`link(' ', $link)` to actually call `CreateHardLink()` which then
fails, because linking folders is not supported. However, with NTS
builds (as well as on other systems), the $target is found to not
exist, so the function fails without actually attempting to create the
link. This needs further investigation.
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
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');
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
require_once __DIR__ . '/windows_links/common.inc';
|
||||
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
@@ -58,7 +59,8 @@ foreach($files as $file) {
|
||||
// create soft link
|
||||
var_dump( symlink($file, $sym_linkname) );
|
||||
// checking information of link with linkinfo()
|
||||
var_dump( linkinfo($sym_linkname) );
|
||||
$linkinfo = linkinfo($sym_linkname);
|
||||
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
|
||||
// checking if given file is soft link
|
||||
var_dump( is_link($sym_linkname) );
|
||||
// clear the cache
|
||||
@@ -69,7 +71,8 @@ foreach($files as $file) {
|
||||
// creating hard link
|
||||
var_dump( link($file, $linkname) );
|
||||
// checking information of link with linkinfo()
|
||||
var_dump( linkinfo($linkname) );
|
||||
$linkinfo = linkinfo($sym_linkname);
|
||||
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
|
||||
// checking if given link is soft link; expected: false
|
||||
var_dump( is_link($linkname) );
|
||||
// clear the cache
|
||||
@@ -95,20 +98,20 @@ rmdir($dirname);
|
||||
-- Iteration 1 --
|
||||
-- Testing on soft links --
|
||||
bool(true)
|
||||
int(%d)
|
||||
bool(true)
|
||||
bool(true)
|
||||
-- Testing on hard links --
|
||||
bool(true)
|
||||
int(%d)
|
||||
bool(true)
|
||||
bool(false)
|
||||
|
||||
-- Iteration 2 --
|
||||
-- Testing on soft links --
|
||||
bool(true)
|
||||
int(%d)
|
||||
bool(true)
|
||||
bool(true)
|
||||
-- Testing on hard links --
|
||||
bool(true)
|
||||
int(%d)
|
||||
bool(true)
|
||||
bool(false)
|
||||
Done
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
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');
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
require_once __DIR__ . '/windows_links/common.inc';
|
||||
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
@@ -44,7 +45,8 @@ 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) );
|
||||
$linkinfo = linkinfo($sym_linkname);
|
||||
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
|
||||
// checks if link created is soft link; expected: true
|
||||
var_dump( is_link($sym_linkname) );
|
||||
// clear the cache
|
||||
@@ -60,7 +62,11 @@ var_dump( is_link($linkname) ); // link doesn't exists as not created, expected
|
||||
clearstatcache();
|
||||
|
||||
// deleting the links
|
||||
unlink($sym_linkname);
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
rmdir($sym_linkname);
|
||||
} else {
|
||||
unlink($sym_linkname);
|
||||
}
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
@@ -76,7 +82,7 @@ rmdir($dirname);
|
||||
|
||||
-- Testing on soft links --
|
||||
bool(true)
|
||||
int(%d)
|
||||
bool(true)
|
||||
bool(true)
|
||||
|
||||
-- Testing on hard links --
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
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');
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
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_OS_FAMILY === 'Windows' && PHP_ZTS) {
|
||||
die('xfail different handling of space as filename with ZTS/NTS on Windows');
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
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');
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
require_once __DIR__ . '/windows_links/common.inc';
|
||||
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
@@ -47,7 +48,8 @@ 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) );
|
||||
$linkinfo = linkinfo($obj->linkname);
|
||||
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
|
||||
// check if link is soft link
|
||||
var_dump( is_link($obj->linkname) );
|
||||
// delete the link created
|
||||
@@ -60,7 +62,8 @@ 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) );
|
||||
$linkinfo = linkinfo($obj->linkname);
|
||||
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
|
||||
// check if link is soft link; expected: false as the link is a hardlink
|
||||
var_dump( is_link($obj->linkname) );
|
||||
// delete the link created
|
||||
@@ -77,7 +80,8 @@ 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]) );
|
||||
$linkinfo = linkinfo($link_arr[0]);
|
||||
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
|
||||
// check if link is soft link
|
||||
var_dump( is_link($link_arr[0]) );
|
||||
// delete the link created
|
||||
@@ -90,7 +94,8 @@ 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]) );
|
||||
$linkinfo = linkinfo($link_arr[0]);
|
||||
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
|
||||
// check if link is soft link; expected: false as this is a hardlink
|
||||
var_dump( is_link($link_arr[0]) );
|
||||
// delete the links created
|
||||
@@ -114,23 +119,23 @@ rmdir($dirname);
|
||||
|
||||
-- Working with soft links --
|
||||
bool(true)
|
||||
int(%d)
|
||||
bool(true)
|
||||
bool(true)
|
||||
|
||||
-- Working with hard links --
|
||||
bool(true)
|
||||
int(%d)
|
||||
bool(true)
|
||||
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)
|
||||
bool(true)
|
||||
|
||||
-- Working with hard links --
|
||||
bool(true)
|
||||
int(%d)
|
||||
bool(true)
|
||||
bool(false)
|
||||
Done
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
--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 );
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
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');
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
require_once __DIR__ . '/windows_links/common.inc';
|
||||
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
--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 );
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
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');
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
require_once __DIR__ . '/windows_links/common.inc';
|
||||
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
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');
|
||||
}
|
||||
require __DIR__ . '/../skipif_root.inc';
|
||||
?>
|
||||
--FILE--
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
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');
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
require_once __DIR__ . '/windows_links/common.inc';
|
||||
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
@@ -51,7 +52,11 @@ var_dump( symlink($dirname, $linkname) );
|
||||
// create another link to $dirname
|
||||
var_dump( symlink($linkname, $linkname) );
|
||||
// delete link
|
||||
unlink($linkname);
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
rmdir($linkname);
|
||||
} else {
|
||||
unlink($linkname);
|
||||
}
|
||||
|
||||
echo "\n*** Create hard link to file and then to itself ***\n";
|
||||
// create hard link to $filename
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
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');
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
require_once __DIR__ . '/windows_links/common.inc';
|
||||
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
@@ -77,7 +78,7 @@ bool(true)
|
||||
|
||||
*** Create soft link in different directory with same filename ***
|
||||
|
||||
Warning: symlink(): File exists in %s on line %d
|
||||
Warning: symlink(): %rFile exists|Permission denied%r in %s on line %d
|
||||
bool(false)
|
||||
bool(true)
|
||||
Done
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
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');
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
require_once __DIR__ . '/windows_links/common.inc';
|
||||
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
@@ -45,8 +46,8 @@ 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";
|
||||
echo "linkinfo() returns integer !== -1: ";
|
||||
var_dump(is_int($linkinfo) && $linkinfo !== -1);
|
||||
if( $s1[0] == $linkinfo )
|
||||
echo "\nlinkinfo() value matches lstat['dev']\n";
|
||||
else
|
||||
@@ -60,8 +61,8 @@ 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";
|
||||
echo "linkinfo() returns integer !== -1: ";
|
||||
var_dump(is_int($linkinfo) && $linkinfo !== -1);
|
||||
if( $s1[0] == $linkinfo )
|
||||
echo "\nlinkinfo() value matches lstat['dev']\n";
|
||||
else
|
||||
@@ -77,15 +78,19 @@ 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";
|
||||
echo "linkinfo() returns integer !== -1: ";
|
||||
var_dump(is_int($linkinfo) && $linkinfo !== -1);
|
||||
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);
|
||||
if (PHP_OS_FAMILY === 'Windows') {
|
||||
rmdir($soft_link);
|
||||
} else {
|
||||
unlink($soft_link);
|
||||
}
|
||||
|
||||
echo "Done\n";
|
||||
?>
|
||||
@@ -100,22 +105,19 @@ rmdir($dirname);
|
||||
--EXPECTF--
|
||||
*** Checking lstat() on soft link ***
|
||||
bool(true)
|
||||
linkinfo() returns : %d
|
||||
lstat() returns lstat['dev'] as %d
|
||||
linkinfo() returns integer !== -1: bool(true)
|
||||
|
||||
linkinfo() value matches lstat['dev']
|
||||
|
||||
*** Checking lstat() on hard link ***
|
||||
bool(true)
|
||||
linkinfo() returns : %d
|
||||
lstat() returns lstat['dev'] as %d
|
||||
linkinfo() returns integer !== -1: bool(true)
|
||||
|
||||
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() returns integer !== -1: bool(true)
|
||||
|
||||
linkinfo() value matches lstat['dev']
|
||||
Done
|
||||
|
||||
Reference in New Issue
Block a user