From 8d9b6f04b47a21a60da1ed26e372ef9b0c022aff Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Sat, 30 Jan 2010 17:06:06 +0000 Subject: [PATCH] - fix test, rewrite it (same cases are tested), CS, simplify, be verbose on error not otherwise (avoid infinite loop in pcre_match inside run-test) --- .../tests/file/tempnam_variation3-win32.phpt | 144 +++++++++--------- 1 file changed, 69 insertions(+), 75 deletions(-) diff --git a/ext/standard/tests/file/tempnam_variation3-win32.phpt b/ext/standard/tests/file/tempnam_variation3-win32.phpt index ec7718f970..00f5e1c0e9 100644 --- a/ext/standard/tests/file/tempnam_variation3-win32.phpt +++ b/ext/standard/tests/file/tempnam_variation3-win32.phpt @@ -15,106 +15,100 @@ if(substr(PHP_OS, 0, 3) != "WIN") echo "*** Testing tempnam() with obscure prefixes ***\n"; $file_path = dirname(__FILE__)."/tempnamVar3"; -mkdir($file_path); +if (!mkdir($file_path)) { + echo "Failed, cannot create temp dir $filepath\n"; + exit(1); +} + +$file_path = realpath($file_path); /* An array of prefixes */ $names_arr = array( - /* Invalid args */ - -1, - TRUE, - FALSE, - NULL, - "", - " ", - "\0", - array(), + /* Valid args (casting)*/ + -1, + TRUE, + FALSE, + NULL, + "", + " ", + "\0", + /* Invalid args */ + array(), + + /* Valid args*/ + /* prefix with path separator of a non existing directory*/ + "/no/such/file/dir", + "php/php" +); - /* prefix with path separator of a non existing directory*/ - "/no/such/file/dir", - "php/php" +$res_arr = array( + /* Invalid args */ + true, + true, + true, + true, + true, + true, + true, + false, + /* prefix with path separator of a non existing directory*/ + true, + true ); for( $i=0; $i "; - print($file_name); - echo "\n"; + /* creating the files in existing dir */ + if (file_exists($file_name) && !$res_arr[$i]) { + echo "Failed\n"; + } + if ($res_arr[$i]) { + $file_dir = dirname($file_name); + if (realpath($file_dir) == $file_path || realpath($file_dir . "\\") == $file_path) { + echo "OK\n"; + } else { + echo "Failed, not created in the correct directory" . realpath($file_dir) . ' vs ' . $file_path ."\n"; + } + + if (!is_writable($file_name)) { + printf("%o\n", fileperms($file_name) ); - echo "File permissions are => "; - printf("%o", fileperms($file_name) ); - echo "\n"; - - echo "File created in => "; - $file_dir = dirname($file_name); - if (realpath($file_dir) == realpath(sys_get_temp_dir()) || realpath($file_dir."\\") == realpath(sys_get_temp_dir())) { - echo "temp dir\n"; - } - else if (realpath($file_dir) == realpath($file_path) || realpath($file_dir."\\") == realpath($file_path)) { - echo "directory specified\n"; - } - else { - echo "unknown location\n"; - } - } - else { - echo "-- File is not created --\n"; - } - - unlink($file_name); + } + } else { + echo "OK\n"; + } + @unlink($file_name); } rmdir($file_path); -echo "\n*** Done ***\n"; +echo "\n*** Done. ***\n"; ?> --EXPECTF-- *** Testing tempnam() with obscure prefixes *** -- Iteration 0 -- -File name is => %s\%s -File permissions are => 100666 -File created in => directory specified +OK -- Iteration 1 -- -File name is => %s\%s -File permissions are => 100666 -File created in => directory specified +OK -- Iteration 2 -- -File name is => %s\%s -File permissions are => 100666 -File created in => directory specified +OK -- Iteration 3 -- -File name is => %s\%s -File permissions are => 100666 -File created in => directory specified +OK -- Iteration 4 -- -File name is => %s\%s -File permissions are => 100666 -File created in => directory specified +OK -- Iteration 5 -- -File name is => %s\%s -File permissions are => 100666 -File created in => directory specified +OK -- Iteration 6 -- -File name is => %s\%s -File permissions are => 100666 -File created in => directory specified +OK -- Iteration 7 -- -Warning: tempnam() expects parameter 2 to be string, array given in %s on line %d --- File is not created -- - -Warning: unlink(): No such file or directory in %s on line %d +Warning: tempnam() expects parameter 2 to be string, array given in %s\ext\standard\tests\file\tempnam_variation3-win32.php on line %d +OK -- Iteration 8 -- -File name is => %s\di%s -File permissions are => 100666 -File created in => directory specified +OK -- Iteration 9 -- -File name is => %s\ph%s -File permissions are => 100666 -File created in => directory specified - -*** Done *** +OK +*** Done. *** -- 2.50.1