pajoye Sat, 30 Jan 2010 17:06:06 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=294251
Log: - 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) Changed paths: U php/php-src/branches/PHP_5_3/ext/standard/tests/file/tempnam_variation3-win32.phpt U php/php-src/trunk/ext/standard/tests/file/tempnam_variation3-win32.phpt
Modified: php/php-src/branches/PHP_5_3/ext/standard/tests/file/tempnam_variation3-win32.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/standard/tests/file/tempnam_variation3-win32.phpt 2010-01-30 16:44:46 UTC (rev 294250) +++ php/php-src/branches/PHP_5_3/ext/standard/tests/file/tempnam_variation3-win32.phpt 2010-01-30 17:06:06 UTC (rev 294251) @@ -15,106 +15,100 @@ 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(), - /* prefix with path separator of a non existing directory*/ - "/no/such/file/dir", - "php/php" + /* Valid args*/ + /* 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<count($names_arr); $i++ ) { - echo "-- Iteration $i --\n"; - $file_name = tempnam("$file_path", $names_arr[$i]); + echo "-- Iteration $i --\n"; + $file_name = tempnam($file_path, $names_arr[$i]); - /* creating the files in existing dir */ - if( file_exists($file_name) ) { - echo "File name is => "; - 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 +OK -*** Done *** - +*** Done. *** Modified: php/php-src/trunk/ext/standard/tests/file/tempnam_variation3-win32.phpt =================================================================== --- php/php-src/trunk/ext/standard/tests/file/tempnam_variation3-win32.phpt 2010-01-30 16:44:46 UTC (rev 294250) +++ php/php-src/trunk/ext/standard/tests/file/tempnam_variation3-win32.phpt 2010-01-30 17:06:06 UTC (rev 294251) @@ -15,106 +15,100 @@ 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(), - /* prefix with path separator of a non existing directory*/ - "/no/such/file/dir", - "php/php" + /* Valid args*/ + /* 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<count($names_arr); $i++ ) { - echo "-- Iteration $i --\n"; - $file_name = tempnam("$file_path", $names_arr[$i]); + echo "-- Iteration $i --\n"; + $file_name = tempnam($file_path, $names_arr[$i]); - /* creating the files in existing dir */ - if( file_exists($file_name) ) { - echo "File name is => "; - 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 -- -Notice: Array to string conversion in %sp on line %d -File name is => %s\%s -File permissions are => 100666 -File created in => directory specified +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 +OK -*** Done *** - +*** Done. ***
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php