Fix bug 61746 Failing tests in ext/standard/tests/file/windows_links/*

Fixed that again for systems having their %SYSTEMROOT% not in
c:\windows
This commit is contained in:
Matt Ficken 2012-05-08 19:31:41 +02:00 committed by Anatoliy Belsky
parent 838b4b8ff7
commit c12fdbde5f
5 changed files with 42 additions and 11 deletions

View file

@ -9,7 +9,8 @@ Venkat Raman Don (don.raman@microsoft.com)
if(substr(PHP_OS, 0, 3) != 'WIN' ) { if(substr(PHP_OS, 0, 3) != 'WIN' ) {
die('skip windows only test'); die('skip windows only test');
} }
$cmd = "mklink.exe /?"; include_once __DIR__ . '/common.inc';
$cmd = "mklink /?";
$ret = @exec($cmd, $output, $return_val); $ret = @exec($cmd, $output, $return_val);
if (count($output) == 0) { if (count($output) == 0) {
die("mklink.exe not found in PATH"); die("mklink.exe not found in PATH");
@ -17,7 +18,8 @@ if (count($output) == 0) {
?> ?>
--FILE-- --FILE--
<?php <?php
$mountvol = "c:\\Windows\\System32\\mountvol.exe"; include_once __DIR__ . '/common.inc';
$mountvol = get_mountvol();
$old_dir = __DIR__; $old_dir = __DIR__;
$dirname = __DIR__ . "\\mnt\\test\\directory"; $dirname = __DIR__ . "\\mnt\\test\\directory";
mkdir($dirname, 0700, true); mkdir($dirname, 0700, true);

View file

@ -9,7 +9,8 @@ Venkat Raman Don (don.raman@microsoft.com)
if(substr(PHP_OS, 0, 3) != 'WIN' ) { if(substr(PHP_OS, 0, 3) != 'WIN' ) {
die('skip windows only test'); die('skip windows only test');
} }
$cmd = "mklink.exe /?"; include_once __DIR__ . '/common.inc';
$cmd = "mklink /?";
$ret = @exec($cmd, $output, $return_val); $ret = @exec($cmd, $output, $return_val);
if (count($output) == 0) { if (count($output) == 0) {
die("mklink.exe not found in PATH"); die("mklink.exe not found in PATH");
@ -17,7 +18,8 @@ if (count($output) == 0) {
?> ?>
--FILE-- --FILE--
<?php <?php
$mountvol = "c:\\Windows\\System32\\mountvol.exe"; include_once __DIR__ . '/common.inc';
$mountvol = get_mountvol();
$old_dir = __DIR__; $old_dir = __DIR__;
$dirname = __DIR__ . "\\mnt\\test\\directory"; $dirname = __DIR__ . "\\mnt\\test\\directory";
exec("mkdir " . $dirname, $output, $ret_val); exec("mkdir " . $dirname, $output, $ret_val);
@ -54,4 +56,4 @@ I am included.
I am included. I am included.
bool(true) bool(true)
bool(true) bool(true)
bool(true) bool(true)

View file

@ -9,15 +9,17 @@ Venkat Raman Don (don.raman@microsoft.com)
if(substr(PHP_OS, 0, 3) != 'WIN' ) { if(substr(PHP_OS, 0, 3) != 'WIN' ) {
die('skip windows only test'); die('skip windows only test');
} }
include_once __DIR__ . '/common.inc';
$ret = exec('mklink bug48746_tmp.lnk ' . __FILE__ .' 2>&1', $out); $ret = exec('mklink bug48746_tmp.lnk ' . __FILE__ .' 2>&1', $out);
if (strpos($ret, 'privilege')) { if (strpos($ret, 'privilege')) {
die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.'); die('skip. SeCreateSymbolicLinkPrivilege not enable for this user.');
} }
unlink('mklink bug48746_tmp.lnk'); unlink('bug48746_tmp.lnk');
?> ?>
--FILE-- --FILE--
<?php <?php
$mountvol = "c:\\Windows\\System32\\mountvol.exe"; include_once __DIR__ . '/common.inc';
$mountvol = get_mountvol();
$old_dir = __DIR__; $old_dir = __DIR__;
$dirname = __DIR__ . "\\mnt\\test\\directory"; $dirname = __DIR__ . "\\mnt\\test\\directory";
exec("mkdir " . $dirname, $output, $ret_val); exec("mkdir " . $dirname, $output, $ret_val);
@ -64,4 +66,4 @@ Array
[1] => .. [1] => ..
[2] => a.php [2] => a.php
[3] => b.php [3] => b.php
) )

View file

@ -9,7 +9,8 @@ Venkat Raman Don (don.raman@microsoft.com)
if(substr(PHP_OS, 0, 3) != 'WIN' ) { if(substr(PHP_OS, 0, 3) != 'WIN' ) {
die('skip windows only test'); die('skip windows only test');
} }
$ret = exec('junction /? 2>&1', $out); include_once __DIR__ . '/common.inc';
$ret = exec(get_junction().' /? 2>&1', $out);
if (strpos($out[0], 'recognized')) { if (strpos($out[0], 'recognized')) {
die('skip. junction.exe not found in PATH.'); die('skip. junction.exe not found in PATH.');
} }
@ -17,11 +18,12 @@ if (strpos($out[0], 'recognized')) {
?> ?>
--FILE-- --FILE--
<?php <?php
include_once __DIR__ . '/common.inc';
$old_dir = __DIR__; $old_dir = __DIR__;
$dirname = __DIR__ . "\\mnt\\test\\directory"; $dirname = __DIR__ . "\\mnt\\test\\directory";
exec("mkdir " . $dirname, $output, $ret_val); exec("mkdir " . $dirname, $output, $ret_val);
chdir(__DIR__ . "\\mnt\\test"); chdir(__DIR__ . "\\mnt\\test");
exec("junction junction directory", $output, $ret_val); exec(get_junction()." junction directory", $output, $ret_val);
file_put_contents("junction\\a.php", "<?php echo \"I am included.\n\" ?>"); file_put_contents("junction\\a.php", "<?php echo \"I am included.\n\" ?>");
file_put_contents("junction\\b.php", "<?php echo \"I am included.\n\" ?>"); file_put_contents("junction\\b.php", "<?php echo \"I am included.\n\" ?>");
include "junction/a.php"; include "junction/a.php";
@ -45,4 +47,4 @@ Array
[1] => .. [1] => ..
[2] => a.php [2] => a.php
[3] => b.php [3] => b.php
) )

View file

@ -0,0 +1,23 @@
<?php
function get_sysroot() {
// usually c:\\windows, but not always
return exec('echo %SYSTEMROOT%');
}
function get_junction(){
// junction.exe isn't included with Windows
// its a sysinternals tool for working with filesystem links
// see: http://technet.microsoft.com/en-us/sysinternals/bb896768
// install somewhere that is on %path% or added to %path%
return "junction.exe";
}
function get_mountvol() {
$sysroot = get_sysroot();
return "$sysroot\\System32\\mountvol.exe";
}
?>