summaryrefslogtreecommitdiff
path: root/ext/standard/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/tests')
-rw-r--r--ext/standard/tests/dir/dir_variation3.phpt10
-rw-r--r--ext/standard/tests/dir/dir_variation7.phpt10
-rw-r--r--ext/standard/tests/dir/opendir_variation5.phpt10
-rw-r--r--ext/standard/tests/dir/opendir_variation7.phpt10
-rw-r--r--ext/standard/tests/dir/readdir_variation5.phpt10
-rw-r--r--ext/standard/tests/dir/scandir_variation5.phpt10
-rw-r--r--ext/standard/tests/dir/scandir_variation7.phpt10
-rw-r--r--ext/standard/tests/file/006_basic.phpt12
-rw-r--r--ext/standard/tests/file/006_error.phpt12
-rw-r--r--ext/standard/tests/file/006_variation1.phpt12
-rw-r--r--ext/standard/tests/file/006_variation2.phpt12
-rw-r--r--ext/standard/tests/file/copy_variation15.phpt10
-rw-r--r--ext/standard/tests/file/copy_variation9.phpt11
-rw-r--r--ext/standard/tests/file/is_executable_basic.phpt11
-rw-r--r--ext/standard/tests/file/is_executable_variation2.phpt11
-rw-r--r--ext/standard/tests/file/is_executable_variation3.phpt11
-rw-r--r--ext/standard/tests/file/is_readable_basic.phpt11
-rw-r--r--ext/standard/tests/file/is_readable_variation1.phpt12
-rw-r--r--ext/standard/tests/file/is_readable_variation2.phpt10
-rw-r--r--ext/standard/tests/file/is_readable_variation3.phpt13
-rw-r--r--ext/standard/tests/file/is_writable_basic.phpt11
-rw-r--r--ext/standard/tests/file/is_writable_variation1.phpt14
-rw-r--r--ext/standard/tests/file/is_writable_variation2.phpt11
-rw-r--r--ext/standard/tests/file/is_writable_variation3.phpt12
-rw-r--r--ext/standard/tests/file/lchown_error.phpt10
-rw-r--r--ext/standard/tests/file/mkdir_rmdir_variation1.phpt11
-rw-r--r--ext/standard/tests/file/mkdir_rmdir_variation2.phpt11
-rw-r--r--ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt12
-rw-r--r--ext/standard/tests/file/tempnam_variation4-0.phpt10
-rw-r--r--ext/standard/tests/file/tempnam_variation4-1.phpt10
-rw-r--r--ext/standard/tests/file/unlink_variation1.phpt11
-rw-r--r--ext/standard/tests/skipif_root.inc16
32 files changed, 47 insertions, 310 deletions
diff --git a/ext/standard/tests/dir/dir_variation3.phpt b/ext/standard/tests/dir/dir_variation3.phpt
index 041304eba4..b79b2befe4 100644
--- a/ext/standard/tests/dir/dir_variation3.phpt
+++ b/ext/standard/tests/dir/dir_variation3.phpt
@@ -5,15 +5,7 @@ Test dir() function : usage variations - different directory permissions
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/dir_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip...cannot be run as root\n');
-}
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/dir/dir_variation7.phpt b/ext/standard/tests/dir/dir_variation7.phpt
index e069043fe3..c2e6519dfe 100644
--- a/ext/standard/tests/dir/dir_variation7.phpt
+++ b/ext/standard/tests/dir/dir_variation7.phpt
@@ -5,15 +5,7 @@ Test dir() function : usage variations - directories with restricted permissions
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/dir_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip...cannot be run as root\n');
-}
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/dir/opendir_variation5.phpt b/ext/standard/tests/dir/opendir_variation5.phpt
index ac12930280..937911227c 100644
--- a/ext/standard/tests/dir/opendir_variation5.phpt
+++ b/ext/standard/tests/dir/opendir_variation5.phpt
@@ -5,15 +5,7 @@ Test opendir() function : usage variations - directories with restricted permiss
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/dir_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip...cannot be run as root\n');
-}
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/dir/opendir_variation7.phpt b/ext/standard/tests/dir/opendir_variation7.phpt
index d468f27008..d781c4f538 100644
--- a/ext/standard/tests/dir/opendir_variation7.phpt
+++ b/ext/standard/tests/dir/opendir_variation7.phpt
@@ -5,15 +5,7 @@ Test opendir() function : usage variations - different directory permissions
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__ . "/opendir_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip...cannot be run as root\n');
-}
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/dir/readdir_variation5.phpt b/ext/standard/tests/dir/readdir_variation5.phpt
index 575a4000ac..72ec24a9d8 100644
--- a/ext/standard/tests/dir/readdir_variation5.phpt
+++ b/ext/standard/tests/dir/readdir_variation5.phpt
@@ -5,15 +5,7 @@ Test readdir() function : usage variations - different permissions
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/readdir_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip...cannot be run as root\n');
-}
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/dir/scandir_variation5.phpt b/ext/standard/tests/dir/scandir_variation5.phpt
index 47539c493f..189687f1d0 100644
--- a/ext/standard/tests/dir/scandir_variation5.phpt
+++ b/ext/standard/tests/dir/scandir_variation5.phpt
@@ -5,15 +5,7 @@ Test scandir() function : usage variations - different directory permissions
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/dir_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip...cannot be run as root\n');
-}
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/dir/scandir_variation7.phpt b/ext/standard/tests/dir/scandir_variation7.phpt
index b0305a6e03..bd0cb74a15 100644
--- a/ext/standard/tests/dir/scandir_variation7.phpt
+++ b/ext/standard/tests/dir/scandir_variation7.phpt
@@ -5,15 +5,7 @@ Test scandir() function : usage variations - different directory permissions
if( substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not for Windows');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__ . "/dir_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip...cannot be run as root\n');
-}
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/006_basic.phpt b/ext/standard/tests/file/006_basic.phpt
index 553e8445f1..43c9b86ab0 100644
--- a/ext/standard/tests/file/006_basic.phpt
+++ b/ext/standard/tests/file/006_basic.phpt
@@ -5,17 +5,7 @@ Test fileperms() & chmod() functions: basic functionality
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not on Windows');
}
-// Skip if being run by root
-$filename = __DIR__."/006_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink($filename);
-
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/006_error.phpt b/ext/standard/tests/file/006_error.phpt
index 82e623350a..9234922790 100644
--- a/ext/standard/tests/file/006_error.phpt
+++ b/ext/standard/tests/file/006_error.phpt
@@ -5,17 +5,7 @@ Test fileperms(), chmod() functions: error conditions
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not on Windows');
}
-// Skip if being run by root
-$filename = __DIR__."/006_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink($filename);
-
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/006_variation1.phpt b/ext/standard/tests/file/006_variation1.phpt
index 102bc28432..5a90ea6fb3 100644
--- a/ext/standard/tests/file/006_variation1.phpt
+++ b/ext/standard/tests/file/006_variation1.phpt
@@ -5,17 +5,7 @@ Test fileperms() & chmod() functions: usage variation - perms(0000-0777)
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not on Windows');
}
-// Skip if being run by root
-$filename = __DIR__."/006_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink($filename);
-
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/006_variation2.phpt b/ext/standard/tests/file/006_variation2.phpt
index 6ae459df0c..a5c95ab1da 100644
--- a/ext/standard/tests/file/006_variation2.phpt
+++ b/ext/standard/tests/file/006_variation2.phpt
@@ -5,17 +5,7 @@ Test fileperms() & chmod() functions: usage variation - misc. perms
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not on Windows');
}
-// Skip if being run by root
-$filename = __DIR__."/006_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink($filename);
-
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/copy_variation15.phpt b/ext/standard/tests/file/copy_variation15.phpt
index a641a8675a..6b52eb7f9b 100644
--- a/ext/standard/tests/file/copy_variation15.phpt
+++ b/ext/standard/tests/file/copy_variation15.phpt
@@ -4,15 +4,7 @@ Test copy() function: usage variations - destination dir access perms
<?php
if(substr(PHP_OS, 0, 3) == 'WIN')
die("skip do not run on Windows");
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/copy_variation15_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/copy_variation9.phpt b/ext/standard/tests/file/copy_variation9.phpt
index c0651a7375..2c1005ec64 100644
--- a/ext/standard/tests/file/copy_variation9.phpt
+++ b/ext/standard/tests/file/copy_variation9.phpt
@@ -4,16 +4,7 @@ Test copy() function: usage variations - destination file access perms
<?php
if(substr(PHP_OS, 0, 3) == 'WIN')
die("skip do not run on Windows");
-
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/copy_variation9_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/is_executable_basic.phpt b/ext/standard/tests/file/is_executable_basic.phpt
index ef2d2388cf..6c78d2be03 100644
--- a/ext/standard/tests/file/is_executable_basic.phpt
+++ b/ext/standard/tests/file/is_executable_basic.phpt
@@ -5,16 +5,7 @@ Test is_executable() function: basic functionality
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip not for windows');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/is_executable_basic_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/is_executable_variation2.phpt b/ext/standard/tests/file/is_executable_variation2.phpt
index 935b5548f2..5b07f683d3 100644
--- a/ext/standard/tests/file/is_executable_variation2.phpt
+++ b/ext/standard/tests/file/is_executable_variation2.phpt
@@ -5,16 +5,7 @@ Test is_executable() function: usage variations - file/dir with diff. perms
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip not for windows');
}
-// Skip if being run by root
-$filename = __DIR__."/is_executable_variation2_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/is_executable_variation3.phpt b/ext/standard/tests/file/is_executable_variation3.phpt
index 64c018c9b1..92ad3320d3 100644
--- a/ext/standard/tests/file/is_executable_variation3.phpt
+++ b/ext/standard/tests/file/is_executable_variation3.phpt
@@ -5,16 +5,7 @@ Test is_executable() function: usage variations - invalid file names
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip not for windows');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/is_executable_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/is_readable_basic.phpt b/ext/standard/tests/file/is_readable_basic.phpt
index 5df3e36ddd..a3f72a3048 100644
--- a/ext/standard/tests/file/is_readable_basic.phpt
+++ b/ext/standard/tests/file/is_readable_basic.phpt
@@ -5,16 +5,7 @@ Test is_readable() function: basic functionality
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip not for windows');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/is_readable_basic_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/is_readable_variation1.phpt b/ext/standard/tests/file/is_readable_variation1.phpt
index 5ea3e9f928..ab2e591ad5 100644
--- a/ext/standard/tests/file/is_readable_variation1.phpt
+++ b/ext/standard/tests/file/is_readable_variation1.phpt
@@ -2,17 +2,7 @@
Test is_readable() function: usage variations - diff. file notations
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) != 'WIN') {
- // Skip if being run by root (files are always readable, writeable and executable)
- $filename = __DIR__."/is_readable_variation1_root_check.tmp";
- $fp = fopen($filename, 'w');
- fclose($fp);
- if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
- }
- unlink($filename);
-}
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/is_readable_variation2.phpt b/ext/standard/tests/file/is_readable_variation2.phpt
index dccee47c92..1dd4ffd06a 100644
--- a/ext/standard/tests/file/is_readable_variation2.phpt
+++ b/ext/standard/tests/file/is_readable_variation2.phpt
@@ -5,15 +5,7 @@ Test is_readable() function: usage variations - file/dir with diff. perms
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip not for windows');
}
-// Skip if being run by root
-$filename = __DIR__."/is_readable_variation2_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/is_readable_variation3.phpt b/ext/standard/tests/file/is_readable_variation3.phpt
index aeb006b2f0..9a80792c00 100644
--- a/ext/standard/tests/file/is_readable_variation3.phpt
+++ b/ext/standard/tests/file/is_readable_variation3.phpt
@@ -2,18 +2,7 @@
Test is_readable() function: usage variations - invalid file names
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) != 'WIN') {
-
- // Skip if being run by root (files are always readable, writeable and executable)
- $filename = __DIR__."/is_readable_variation3_root_check.tmp";
- $fp = fopen($filename, 'w');
- fclose($fp);
- if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
- }
- unlink($filename);
-}
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/is_writable_basic.phpt b/ext/standard/tests/file/is_writable_basic.phpt
index ad0660bdfd..ba6676836d 100644
--- a/ext/standard/tests/file/is_writable_basic.phpt
+++ b/ext/standard/tests/file/is_writable_basic.phpt
@@ -2,16 +2,7 @@
Test is_writable() and its alias is_writeable() function: basic functionality
--SKIPIF--
<?php
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/is_writable_basic_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/is_writable_variation1.phpt b/ext/standard/tests/file/is_writable_variation1.phpt
index 15f1290588..45ef1524b6 100644
--- a/ext/standard/tests/file/is_writable_variation1.phpt
+++ b/ext/standard/tests/file/is_writable_variation1.phpt
@@ -2,19 +2,7 @@
Test is_writable() and its alias is_writeable() function: usage variations - diff. path notations
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) != 'WIN') {
-
- // Skip if being run by root (files are always readable, writeable and executable)
- $filename = __DIR__."/is_writable_root_check.tmp";
- $fp = fopen($filename, 'w');
- fclose($fp);
- if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
- }
-
- unlink($filename);
-}
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/is_writable_variation2.phpt b/ext/standard/tests/file/is_writable_variation2.phpt
index eb75cf895f..def45bd2a0 100644
--- a/ext/standard/tests/file/is_writable_variation2.phpt
+++ b/ext/standard/tests/file/is_writable_variation2.phpt
@@ -5,16 +5,7 @@ Test is_writable() and its alias is_writeable() function: usage variations - fil
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip.. only on LINUX');
}
-// Skip if being run by root
-$filename = __DIR__."/is_writable_variation2_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink ($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/is_writable_variation3.phpt b/ext/standard/tests/file/is_writable_variation3.phpt
index c8909b0932..b55a193fce 100644
--- a/ext/standard/tests/file/is_writable_variation3.phpt
+++ b/ext/standard/tests/file/is_writable_variation3.phpt
@@ -2,17 +2,7 @@
Test is_writable() and its alias is_writeable() function: usage variations - invalid file names
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) != 'WIN') {
- // Skip if being run by root (files are always readable, writeable and executable)
- $filename = __DIR__."/is_writable_root_check.tmp";
- $fp = fopen($filename, 'w');
- fclose($fp);
- if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
- }
- unlink($filename);
-}
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/lchown_error.phpt b/ext/standard/tests/file/lchown_error.phpt
index 0e2b59e016..5f9e8dbe69 100644
--- a/ext/standard/tests/file/lchown_error.phpt
+++ b/ext/standard/tests/file/lchown_error.phpt
@@ -4,15 +4,7 @@ Test lchown() function : error functionality
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') die('skip no windows support');
if (!function_exists("posix_getuid")) die("skip no posix_getuid()");
-// Skip if being run by root
-$filename = __DIR__."/lchow_error_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/mkdir_rmdir_variation1.phpt b/ext/standard/tests/file/mkdir_rmdir_variation1.phpt
index 9457364643..6fe177250c 100644
--- a/ext/standard/tests/file/mkdir_rmdir_variation1.phpt
+++ b/ext/standard/tests/file/mkdir_rmdir_variation1.phpt
@@ -5,16 +5,7 @@ Test mkdir() and rmdir() functions: usage variations - perms(0000-0777)
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip.. only on LINUX');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/mkdir_rmdir_variation1_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/mkdir_rmdir_variation2.phpt b/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
index 7ad6714870..8712d52604 100644
--- a/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
+++ b/ext/standard/tests/file/mkdir_rmdir_variation2.phpt
@@ -5,16 +5,7 @@ Test mkdir() and rmdir() functions: usage variations - misc.
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip.. only on LINUX');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/mkdir_rmdir_variation2_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt
index 3a829580ea..8095972b73 100644
--- a/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt
+++ b/ext/standard/tests/file/symlink_link_linkinfo_is_link_variation6.phpt
@@ -5,17 +5,7 @@ Test symlink(), linkinfo(), link() and is_link() functions : usage variations -
if ( substr(PHP_OS, 0, 3) == 'WIN' ) {
die('skip no symlinks on Windows');
}
-
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/symlink_link_linkinfo_is_link6_check_root.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/tempnam_variation4-0.phpt b/ext/standard/tests/file/tempnam_variation4-0.phpt
index 4232ef0b08..646179beca 100644
--- a/ext/standard/tests/file/tempnam_variation4-0.phpt
+++ b/ext/standard/tests/file/tempnam_variation4-0.phpt
@@ -5,15 +5,7 @@ Test tempnam() function: usage variations - permissions(0000 to 0350) of dir
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not valid for Windows');
}
-// Skip if being run by root
-$filename = __DIR__."/tempnam_variation4-0_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/tempnam_variation4-1.phpt b/ext/standard/tests/file/tempnam_variation4-1.phpt
index 48d450d922..b614404c94 100644
--- a/ext/standard/tests/file/tempnam_variation4-1.phpt
+++ b/ext/standard/tests/file/tempnam_variation4-1.phpt
@@ -5,15 +5,7 @@ Test tempnam() function: usage variations - permissions(0351 to 0777) of dir
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip Not valid for Windows');
}
-// Skip if being run by root
-$filename = __DIR__."/tempnam_variation4-1_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/file/unlink_variation1.phpt b/ext/standard/tests/file/unlink_variation1.phpt
index 0ce7cdf74f..1c4569a5fd 100644
--- a/ext/standard/tests/file/unlink_variation1.phpt
+++ b/ext/standard/tests/file/unlink_variation1.phpt
@@ -5,16 +5,7 @@ Test unlink() function : usage variations - unlinking file in a directory
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('skip only on Linux');
}
-// Skip if being run by root (files are always readable, writeable and executable)
-$filename = __DIR__."/unlink_root_check.tmp";
-$fp = fopen($filename, 'w');
-fclose($fp);
-if(fileowner($filename) == 0) {
- unlink ($filename);
- die('skip cannot be run as root');
-}
-
-unlink($filename);
+require __DIR__ . '/../skipif_root.inc';
?>
--FILE--
<?php
diff --git a/ext/standard/tests/skipif_root.inc b/ext/standard/tests/skipif_root.inc
new file mode 100644
index 0000000000..d43cae8674
--- /dev/null
+++ b/ext/standard/tests/skipif_root.inc
@@ -0,0 +1,16 @@
+<?php
+
+// Skip if being run by root (files are always readable, writeable and executable)
+$filename = @tempnam(__DIR__, 'root_check_');
+if (!file_exists($filename)) {
+ die('WARN Unable to create the "root check" file');
+}
+
+$isRoot = fileowner($filename) == 0;
+
+unlink($filename);
+
+if ($isRoot) {
+ die('SKIP Cannot be run as root');
+}
+