Skip to content

Commit 68293b1

Browse files
committed
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.
1 parent b291c92 commit 68293b1

13 files changed

+74
-68
lines changed

ext/standard/tests/file/symlink_link_linkinfo_is_link_basic1.phpt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Test symlink(), linkinfo(), link() and is_link() functions: basic functionality - link to files
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows') {
6+
require_once __DIR__ . '/windows_links/common.inc';
7+
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
78
}
89
?>
910
--FILE--
@@ -58,7 +59,8 @@ foreach($files as $file) {
5859
// create soft link
5960
var_dump( symlink($file, $sym_linkname) );
6061
// checking information of link with linkinfo()
61-
var_dump( linkinfo($sym_linkname) );
62+
$linkinfo = linkinfo($sym_linkname);
63+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
6264
// checking if given file is soft link
6365
var_dump( is_link($sym_linkname) );
6466
// clear the cache
@@ -69,7 +71,8 @@ foreach($files as $file) {
6971
// creating hard link
7072
var_dump( link($file, $linkname) );
7173
// checking information of link with linkinfo()
72-
var_dump( linkinfo($linkname) );
74+
$linkinfo = linkinfo($sym_linkname);
75+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
7376
// checking if given link is soft link; expected: false
7477
var_dump( is_link($linkname) );
7578
// clear the cache
@@ -95,20 +98,20 @@ rmdir($dirname);
9598
-- Iteration 1 --
9699
-- Testing on soft links --
97100
bool(true)
98-
int(%d)
101+
bool(true)
99102
bool(true)
100103
-- Testing on hard links --
101104
bool(true)
102-
int(%d)
105+
bool(true)
103106
bool(false)
104107

105108
-- Iteration 2 --
106109
-- Testing on soft links --
107110
bool(true)
108-
int(%d)
111+
bool(true)
109112
bool(true)
110113
-- Testing on hard links --
111114
bool(true)
112-
int(%d)
115+
bool(true)
113116
bool(false)
114117
Done

ext/standard/tests/file/symlink_link_linkinfo_is_link_basic2.phpt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Test symlink(), linkinfo(), link() and is_link() functions: basic functionality - link to dirs
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows') {
6+
require_once __DIR__ . '/windows_links/common.inc';
7+
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
78
}
89
?>
910
--FILE--
@@ -44,7 +45,8 @@ echo "\n-- Testing on soft links --\n";
4445
// creating soft link to $dirname
4546
var_dump( symlink("$file_path/$dirname", $sym_linkname) ); // this works, expected true
4647
// gets information about soft link created to directory; expected: true
47-
var_dump( linkinfo($sym_linkname) );
48+
$linkinfo = linkinfo($sym_linkname);
49+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
4850
// checks if link created is soft link; expected: true
4951
var_dump( is_link($sym_linkname) );
5052
// clear the cache
@@ -60,7 +62,11 @@ var_dump( is_link($linkname) ); // link doesn't exists as not created, expected
6062
clearstatcache();
6163

6264
// deleting the links
63-
unlink($sym_linkname);
65+
if (PHP_OS_FAMILY === 'Windows') {
66+
rmdir($sym_linkname);
67+
} else {
68+
unlink($sym_linkname);
69+
}
6470

6571
echo "Done\n";
6672
?>
@@ -76,7 +82,7 @@ rmdir($dirname);
7682

7783
-- Testing on soft links --
7884
bool(true)
79-
int(%d)
85+
bool(true)
8086
bool(true)
8187

8288
-- Testing on hard links --

ext/standard/tests/file/symlink_link_linkinfo_is_link_error1.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : error conditions - symlink & linkinfo
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
7-
}
85
if (substr(PHP_OS, 0, 3) == 'SUN') {
96
die('skip Not valid for Sun Solaris');
107
}

ext/standard/tests/file/symlink_link_linkinfo_is_link_error2.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : error conditions - link & is_link
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows' && PHP_ZTS) {
6+
die('xfail different handling of space as filename with ZTS/NTS on Windows');
77
}
88
?>
99
--FILE--

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation1.phpt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link name stored in an array/object
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows') {
6+
require_once __DIR__ . '/windows_links/common.inc';
7+
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
78
}
89
?>
910
--FILE--
@@ -47,7 +48,8 @@ echo "\n-- Working with soft links --\n";
4748
// creating soft link
4849
var_dump( symlink($filename, $obj->linkname) );
4950
// check if the link exists
50-
var_dump( linkinfo($obj->linkname) );
51+
$linkinfo = linkinfo($obj->linkname);
52+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
5153
// check if link is soft link
5254
var_dump( is_link($obj->linkname) );
5355
// delete the link created
@@ -60,7 +62,8 @@ echo "\n-- Working with hard links --\n";
6062
// creating hard link
6163
var_dump( link($filename, $obj->linkname) );
6264
// check if the link exists
63-
var_dump( linkinfo($obj->linkname) );
65+
$linkinfo = linkinfo($obj->linkname);
66+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
6467
// check if link is soft link; expected: false as the link is a hardlink
6568
var_dump( is_link($obj->linkname) );
6669
// delete the link created
@@ -77,7 +80,8 @@ echo "\n-- Working with soft links --\n";
7780
// creating soft link
7881
var_dump( symlink($filename, $link_arr[0]) );
7982
// check if the link exist
80-
var_dump( linkinfo($link_arr[0]) );
83+
$linkinfo = linkinfo($link_arr[0]);
84+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
8185
// check if link is soft link
8286
var_dump( is_link($link_arr[0]) );
8387
// delete the link created
@@ -90,7 +94,8 @@ echo "\n-- Working with hard links --\n";
9094
// creating hard link
9195
var_dump( link($filename, $link_arr[0]) );
9296
// check if the link exist
93-
var_dump( linkinfo($link_arr[0]) );
97+
$linkinfo = linkinfo($link_arr[0]);
98+
var_dump( is_int($linkinfo) && $linkinfo !== -1 );
9499
// check if link is soft link; expected: false as this is a hardlink
95100
var_dump( is_link($link_arr[0]) );
96101
// delete the links created
@@ -114,23 +119,23 @@ rmdir($dirname);
114119

115120
-- Working with soft links --
116121
bool(true)
117-
int(%d)
122+
bool(true)
118123
bool(true)
119124

120125
-- Working with hard links --
121126
bool(true)
122-
int(%d)
127+
bool(true)
123128
bool(false)
124129

125130
*** Testing symlink(), link(), linkinfo() and is_link() with linknames stored as members of an array ***
126131

127132
-- Working with soft links --
128133
bool(true)
129-
int(%d)
134+
bool(true)
130135
bool(true)
131136

132137
-- Working with hard links --
133138
bool(true)
134-
int(%d)
139+
bool(true)
135140
bool(false)
136141
Done

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation2.phpt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
--TEST--
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - hardlink to non-existent file
3-
--SKIPIF--
4-
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
7-
}
8-
?>
93
--FILE--
104
<?php
115
/* Prototype: bool symlink ( string $target, string $link );

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation3.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - access/update file through softlink
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows') {
6+
require_once __DIR__ . '/windows_links/common.inc';
7+
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
78
}
89
?>
910
--FILE--

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation4.phpt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
--TEST--
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - access/update file through hard link
3-
--SKIPIF--
4-
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
7-
}
8-
?>
93
--FILE--
104
<?php
115
/* Prototype: bool symlink ( string $target, string $link );

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation5.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - work on deleted link
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip no symlinks on Windows');
5+
if (PHP_OS_FAMILY === 'Windows') {
6+
require_once __DIR__ . '/windows_links/common.inc';
7+
skipIfSeCreateSymbolicLinkPrivilegeIsDisabled(__FILE__);
78
}
89
?>
910
--FILE--

ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
Test symlink(), linkinfo(), link() and is_link() functions : usage variations - link & dir perms.
33
--SKIPIF--
44
<?php
5-
if ( substr(PHP_OS, 0, 3) == 'WIN' ) {
6-
die('skip no symlinks on Windows');
7-
}
85
require __DIR__ . '/../skipif_root.inc';
96
?>
107
--FILE--

0 commit comments

Comments
 (0)