From: Gabriel Caruso Date: Sat, 2 Nov 2019 15:29:42 +0000 (+0100) Subject: Fix slowest tests X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fc99e89baf6589409fb8618ea91880b916d9b390;p=php Fix slowest tests --- diff --git a/ext/standard/tests/file/005_variation-win32.phpt b/ext/standard/tests/file/005_variation-win32.phpt index 1e712b7828..42502b6509 100644 --- a/ext/standard/tests/file/005_variation-win32.phpt +++ b/ext/standard/tests/file/005_variation-win32.phpt @@ -40,7 +40,6 @@ function stat_fn( $filename ) { echo "-- inode change time is => "; print( @date( 'Y:M:D:H:i:s', filectime($filename) ) )."\n"; clearstatcache(); - } echo "*** Testing fileattime(), filemtime(), filectime() & touch() : usage variations ***\n"; @@ -49,12 +48,12 @@ $file_path = __DIR__; $file_handle = fopen("$file_path/005_variation1.tmp", "w"); fclose($file_handle); stat_fn("$file_path/005_variation1.tmp"); -sleep(2); +sleep(1); $file_handle = fopen("$file_path/005_variation2.tmp", "w"); fclose($file_handle); stat_fn("$file_path/005_variation2.tmp"); -sleep(2); +sleep(1); $file_handle = fopen("$file_path/005_variation3.tmp", "w"); fclose($file_handle); @@ -70,13 +69,13 @@ $file_name = "$file_path/005_variation1.tmp"; $file_write_handle = fopen($file_name, "w"); fclose($file_write_handle); stat_fn($file_name); -sleep(2); +sleep(1); /* filectime + 2 */ echo "\n-- Checking different times, after changing the file permission --\n"; chmod($file_name, 0777); stat_fn($file_name); -sleep(2); +sleep(1); /* filemtime + 2 & filectime + 2 */ echo "\n-- Checking different times, after writing into the file --\n"; @@ -84,7 +83,7 @@ $file_write_handle = fopen($file_name, "w"); fwrite($file_write_handle, "Hello, world"); fclose($file_write_handle); stat_fn($file_name); -sleep(2); +sleep(1); /* fileatime + 2 */ echo "\n-- Checking different times, after reading from the file --\n"; @@ -92,42 +91,54 @@ $file_read_handle = fopen($file_name ,"r"); fread($file_read_handle, 10); fclose( $file_read_handle); stat_fn($file_name); -sleep(2); +sleep(1); + +/* No change */ +echo "\n-- Checking same times, after creating a softlink to the file --\n"; +symlink($file_name, "$file_path/005_variation_softlink.tmp"); +stat_fn($file_name); +sleep(1); + +/* filectime + 2 */ +echo "\n-- Checking different times, after creating a hardlink to the file --\n"; +link($file_name, "$file_path/005_variation_hardlink.tmp"); +stat_fn($file_name); +sleep(1); /* No change */ -echo "\n-- Checking different times, after making a copy of the file --\n"; +echo "\n-- Checking same times, after making a copy of the file --\n"; $file_copy = "$file_path/005_variation_copy.tmp"; copy($file_name, $file_copy); stat_fn($file_name); -sleep(2); +sleep(1); /* fileatime + 2 */ echo "\n-- Checking different times, after performing is_file() operation on the file --\n"; is_file($file_name); stat_fn($file_name); -sleep(2); +sleep(1); echo "\n*** Testing touch() function with different time values ***\n"; $file_name2 = $file_path."/005_variation_touch.tmp"; $file_handle = fopen($file_name2, "w"); fclose($file_handle); -sleep(2); +sleep(1); /* Time is not mentioned */ var_dump( touch($file_name2) ); //set to current system time stat_fn($file_name2); -sleep(2); +sleep(1); /* set to access(creation time of the file) time */ var_dump( touch($file_name2, @date(fileatime($file_name2))) ); stat_fn($file_name2); -sleep(2); +sleep(1); /* set to access time of $file_name2 */ var_dump( touch($file_path."/005_variation_touch_fly.tmp", @date(fileatime($file_name2)), time()) ); stat_fn($file_name2); -sleep(2); +sleep(1); /* set to default value, with Invalid timestamps */ var_dump( touch($file_name2, 10) ); @@ -184,7 +195,17 @@ unlink($file_path."/005_variation_touch_new.tmp"); -- File modification time is => %d:%s:%s:%d:%d:%d -- inode change time is => %d:%s:%s:%d:%d:%d --- Checking different times, after making a copy of the file -- +-- Checking same times, after creating a softlink to the file -- +-- File access time is => %d:%s:%s:%d:%d:%d +-- File modification time is => %d:%s:%s:%d:%d:%d +-- inode change time is => %d:%s:%s:%d:%d:%d + +-- Checking different times, after creating a hardlink to the file -- +-- File access time is => %d:%s:%s:%d:%d:%d +-- File modification time is => %d:%s:%s:%d:%d:%d +-- inode change time is => %d:%s:%s:%d:%d:%d + +-- Checking same times, after making a copy of the file -- -- File access time is => %d:%s:%s:%d:%d:%d -- File modification time is => %d:%s:%s:%d:%d:%d -- inode change time is => %d:%s:%s:%d:%d:%d diff --git a/ext/standard/tests/file/lstat_stat_variation10.phpt b/ext/standard/tests/file/lstat_stat_variation10.phpt index 16ff75c26d..30578f5d18 100644 --- a/ext/standard/tests/file/lstat_stat_variation10.phpt +++ b/ext/standard/tests/file/lstat_stat_variation10.phpt @@ -31,7 +31,7 @@ echo "*** Testing stat() on directory after using is_dir() on it ***\n"; $old_stat = stat($dirname); // clear the cache clearstatcache(); -sleep(2); +sleep(1); var_dump( is_dir($dirname) ); $new_stat = stat($dirname); diff --git a/ext/standard/tests/file/lstat_stat_variation11.phpt b/ext/standard/tests/file/lstat_stat_variation11.phpt index 9a394ae7e9..523bfacf5c 100644 --- a/ext/standard/tests/file/lstat_stat_variation11.phpt +++ b/ext/standard/tests/file/lstat_stat_variation11.phpt @@ -31,7 +31,7 @@ echo "*** Testing stat() on a file after using is_file() on it ***\n"; $old_stat = stat($filename); // clear the stat clearstatcache(); -sleep(2); +sleep(1); var_dump( is_file($filename) ); $new_stat = stat($filename); // compare self stats diff --git a/ext/standard/tests/file/lstat_stat_variation12.phpt b/ext/standard/tests/file/lstat_stat_variation12.phpt index eada799cdf..15f081f21f 100644 --- a/ext/standard/tests/file/lstat_stat_variation12.phpt +++ b/ext/standard/tests/file/lstat_stat_variation12.phpt @@ -36,7 +36,7 @@ $linkname = "$file_path/lstat_stat_variation12_link.tmp"; $old_stat = lstat($linkname); // clear the stat clearstatcache(); -sleep(2); +sleep(1); var_dump( is_link($linkname) ); $new_stat = lstat($linkname); // compare self stats diff --git a/ext/standard/tests/file/lstat_stat_variation13.phpt b/ext/standard/tests/file/lstat_stat_variation13.phpt index 22694240f5..e94a5085ec 100644 --- a/ext/standard/tests/file/lstat_stat_variation13.phpt +++ b/ext/standard/tests/file/lstat_stat_variation13.phpt @@ -30,7 +30,7 @@ fclose($file_handle); $old_stat = stat($filename); // clear the stat clearstatcache(); -sleep(2); +sleep(1); // opening file again in read mode $file_handle = fopen($filename, "r"); // read file fclose($file_handle); diff --git a/ext/standard/tests/file/lstat_stat_variation16.phpt b/ext/standard/tests/file/lstat_stat_variation16.phpt index 652f5c29c7..93791355ba 100644 --- a/ext/standard/tests/file/lstat_stat_variation16.phpt +++ b/ext/standard/tests/file/lstat_stat_variation16.phpt @@ -28,7 +28,7 @@ fclose($fp); // checking stat() on file after changing its permission echo "*** Testing lstat() on a file after changing its access permission ***\n"; $old_stat = stat($filename); -sleep(2); +sleep(1); var_dump( chmod($filename, 0777) ); // clear the stat clearstatcache(); diff --git a/ext/standard/tests/file/lstat_stat_variation17.phpt b/ext/standard/tests/file/lstat_stat_variation17.phpt index 208cc0b388..64039566f0 100644 --- a/ext/standard/tests/file/lstat_stat_variation17.phpt +++ b/ext/standard/tests/file/lstat_stat_variation17.phpt @@ -27,7 +27,7 @@ $dirname = "$file_path/lstat_stat_variation17"; mkdir($dirname); $old_stat = stat($dirname); -sleep(2); +sleep(1); var_dump( chmod($dirname, 0777) ); // clear the stat clearstatcache(); diff --git a/ext/standard/tests/file/lstat_stat_variation21.phpt b/ext/standard/tests/file/lstat_stat_variation21.phpt index 23ed53e566..df09bc7f98 100644 --- a/ext/standard/tests/file/lstat_stat_variation21.phpt +++ b/ext/standard/tests/file/lstat_stat_variation21.phpt @@ -33,7 +33,7 @@ echo "*** Testing stat() on file by truncating it to given size ***\n"; $old_stat = stat($filename); // clear the cache clearstatcache(); -sleep(2); +sleep(1); // opening file in r/w mode $file_handle = fopen($filename, "r+"); var_dump( ftruncate($file_handle, 512) ); // truncate it diff --git a/ext/standard/tests/file/lstat_stat_variation4.phpt b/ext/standard/tests/file/lstat_stat_variation4.phpt index fe8b61e5ca..c72d7ffe4b 100644 --- a/ext/standard/tests/file/lstat_stat_variation4.phpt +++ b/ext/standard/tests/file/lstat_stat_variation4.phpt @@ -33,7 +33,7 @@ echo "*** Testing stat() for file after using touch() on the file ***\n"; $old_stat = stat($file_name); // clear the cache clearstatcache(); -sleep(2); +sleep(1); var_dump( touch($file_name) ); $new_stat = stat($file_name); diff --git a/ext/standard/tests/file/lstat_stat_variation5.phpt b/ext/standard/tests/file/lstat_stat_variation5.phpt index b5c03c3f08..668e79238d 100644 --- a/ext/standard/tests/file/lstat_stat_variation5.phpt +++ b/ext/standard/tests/file/lstat_stat_variation5.phpt @@ -33,7 +33,7 @@ echo "*** Testing stat() for directory after using touch() on the directory ***\ $old_stat = stat($dir_name); // clear the cache clearstatcache(); -sleep(2); +sleep(1); var_dump( touch($dir_name) ); $new_stat = stat($dir_name); diff --git a/ext/standard/tests/file/lstat_stat_variation8.phpt b/ext/standard/tests/file/lstat_stat_variation8.phpt index db7f87f7f7..9870a56c10 100644 --- a/ext/standard/tests/file/lstat_stat_variation8.phpt +++ b/ext/standard/tests/file/lstat_stat_variation8.phpt @@ -30,7 +30,7 @@ echo "*** Testing stat() on dir after subdir and file is created in it ***\n"; $dirname = "$file_path/lstat_stat_variation8"; $old_stat = stat($dirname); clearstatcache(); -sleep(2); +sleep(1); mkdir("$dirname/lstat_stat_variation8_subdir"); $file_handle = fopen("$dirname/lstat_stat_variation8a.tmp", "w"); fclose($file_handle); diff --git a/ext/standard/tests/file/stat_basic-win32-mb.phpt b/ext/standard/tests/file/stat_basic-win32-mb.phpt index 504e0f45ea..29f1514d76 100644 --- a/ext/standard/tests/file/stat_basic-win32-mb.phpt +++ b/ext/standard/tests/file/stat_basic-win32-mb.phpt @@ -26,7 +26,7 @@ mkdir($dirname); // stat of the dir created $dir_stat = stat($dirname); clearstatcache(); -sleep(2); +sleep(1); // creating file $filename = "$dirname/stat_basic_私はガラスを食べられます.tmp"; @@ -34,7 +34,7 @@ $file_handle = fopen($filename, "w"); fclose($file_handle); // stat of the file created $file_stat = stat($filename); -sleep(2); +sleep(1); // now new stat of the dir after file is created $new_dir_stat = stat($dirname); diff --git a/ext/standard/tests/file/stat_basic-win32.phpt b/ext/standard/tests/file/stat_basic-win32.phpt index 348ac2d380..4df0064688 100644 --- a/ext/standard/tests/file/stat_basic-win32.phpt +++ b/ext/standard/tests/file/stat_basic-win32.phpt @@ -34,7 +34,7 @@ $file_handle = fopen($filename, "w"); fclose($file_handle); // stat of the file created $file_stat = stat($filename); -sleep(2); +sleep(1); // now new stat of the dir after file is created $new_dir_stat = stat($dirname); diff --git a/ext/standard/tests/file/stat_variation1-win32-mb.phpt b/ext/standard/tests/file/stat_variation1-win32-mb.phpt index 1db467632b..002d5ac650 100644 --- a/ext/standard/tests/file/stat_variation1-win32-mb.phpt +++ b/ext/standard/tests/file/stat_variation1-win32-mb.phpt @@ -35,7 +35,7 @@ $old_filename = "$file_path/stat_variation1_私はガラスを食べられます $new_filename = "$file_path/stat_variation1a_私はガラスを食べられます.tmp"; $old_stat = stat($old_filename); clearstatcache(); -sleep(2); +sleep(1); var_dump( rename($old_filename, $new_filename) ); $new_stat = stat($new_filename); diff --git a/ext/standard/tests/file/stat_variation1-win32.phpt b/ext/standard/tests/file/stat_variation1-win32.phpt index 26b1549e02..03d94b8898 100644 --- a/ext/standard/tests/file/stat_variation1-win32.phpt +++ b/ext/standard/tests/file/stat_variation1-win32.phpt @@ -35,7 +35,7 @@ $old_filename = "$file_path/stat_variation1.tmp"; $new_filename = "$file_path/stat_variation1a.tmp"; $old_stat = stat($old_filename); clearstatcache(); -sleep(2); +sleep(1); var_dump( rename($old_filename, $new_filename) ); $new_stat = stat($new_filename); diff --git a/ext/standard/tests/file/stat_variation2-win32.phpt b/ext/standard/tests/file/stat_variation2-win32.phpt index 2d4f44bf02..66347ce2b5 100644 --- a/ext/standard/tests/file/stat_variation2-win32.phpt +++ b/ext/standard/tests/file/stat_variation2-win32.phpt @@ -32,7 +32,7 @@ echo "*** Testing stat(): writing to a file ***\n"; echo "-- Testing stat() on file after data is written in it --\n"; $old_stat = stat($filename); clearstatcache(); -sleep(2); +sleep(1); $file_handle = fopen($filename, "w"); // temp file fwrite($file_handle, "Hello World"); fclose($file_handle); diff --git a/ext/standard/tests/file/stat_variation3-win32.phpt b/ext/standard/tests/file/stat_variation3-win32.phpt index d08612fc7f..980fc56836 100644 --- a/ext/standard/tests/file/stat_variation3-win32.phpt +++ b/ext/standard/tests/file/stat_variation3-win32.phpt @@ -30,7 +30,7 @@ echo "-- Testing stat() on dir after subdir and file is created in it --\n"; $dirname = "$file_path/stat_variation3"; $old_stat = stat($dirname); clearstatcache(); -sleep(2); +sleep(1); mkdir("$dirname/stat_variation3_subdir"); $file_handle = fopen("$dirname/stat_variation3a.tmp", "w"); fclose($file_handle); diff --git a/ext/standard/tests/file/stat_variation4-win32.phpt b/ext/standard/tests/file/stat_variation4-win32.phpt index a5e25f99d0..9cae39a498 100644 --- a/ext/standard/tests/file/stat_variation4-win32.phpt +++ b/ext/standard/tests/file/stat_variation4-win32.phpt @@ -36,7 +36,7 @@ $old_dirname = "$file_path/stat_variation4"; $old_stat = stat($old_dirname); // clear the cache clearstatcache(); -sleep(2); +sleep(1); var_dump( is_dir($old_dirname) ); $new_stat = stat($old_dirname); diff --git a/ext/standard/tests/file/stat_variation5-win32.phpt b/ext/standard/tests/file/stat_variation5-win32.phpt index d2c9fd4c84..47627671db 100644 --- a/ext/standard/tests/file/stat_variation5-win32.phpt +++ b/ext/standard/tests/file/stat_variation5-win32.phpt @@ -32,7 +32,7 @@ fclose($file_handle); $old_stat = stat($filename); // clear the stat clearstatcache(); -sleep(2); +sleep(1); // opening file again in read mode $file_handle = fopen($filename, "r"); // read file fclose($file_handle); diff --git a/ext/standard/tests/file/stat_variation6-win32.phpt b/ext/standard/tests/file/stat_variation6-win32.phpt index 953d7df045..3dc7a4bac1 100644 --- a/ext/standard/tests/file/stat_variation6-win32.phpt +++ b/ext/standard/tests/file/stat_variation6-win32.phpt @@ -32,11 +32,12 @@ fclose($file_handle); // checking stat() on file echo "\n*** Testing stat() on file with miscellaneous file permission and content ***\n"; +clearstatcache(); $old_stat = stat($filename); +sleep(1); var_dump( chmod($filename, 0777) ); // clear the stat clearstatcache(); -sleep(2); $new_stat = stat($filename); // compare self stats var_dump( compare_self_stat($old_stat) ); @@ -50,10 +51,10 @@ clearstatcache(); // clear statement cache // checking stat() on directory echo "\n*** Testing stat() on directory with miscellaneous file permission ***\n"; $old_stat = stat($dirname); +sleep(1); var_dump( chmod($dirname, 0777) ); // clear the stat clearstatcache(); -sleep(2); $new_stat = stat($dirname); // compare self stats var_dump( compare_self_stat($old_stat) ); diff --git a/ext/standard/tests/file/stat_variation8-win32.phpt b/ext/standard/tests/file/stat_variation8-win32.phpt index 7a0cf65d41..c86ba3206e 100644 --- a/ext/standard/tests/file/stat_variation8-win32.phpt +++ b/ext/standard/tests/file/stat_variation8-win32.phpt @@ -37,7 +37,7 @@ fclose($file_handle); clearstatcache(true, $filename); $old_stat = stat($filename); // clear the cache -sleep(2); +sleep(1); // opening file in r/w mode $file_handle = fopen($filename, "r+");