Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/kernel32/tests/file.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c index d1b76bb711..b47b2b9c41 100644 --- a/dlls/kernel32/tests/file.c +++ b/dlls/kernel32/tests/file.c @@ -738,6 +738,14 @@ static void test_CopyFileA(void) ret = CopyFileA(source, dest, FALSE); ok(ret, "CopyFileA: error %d\n", GetLastError());
+ /* NULL checks */ + retok = CopyFileA(NULL, dest, TRUE); + ok(!retok && GetLastError() == ERROR_PATH_NOT_FOUND, + "CopyFileA: ret = %d, unexpected error %d\n", retok, GetLastError()); + retok = CopyFileA(source, NULL, TRUE); + ok(!retok && GetLastError() == ERROR_PATH_NOT_FOUND, + "CopyFileA: ret = %d, unexpected error %d\n", retok, GetLastError()); + /* copying from a read-locked source fails */ hfile = CreateFileA(source, GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %d\n", GetLastError()); @@ -1174,6 +1182,13 @@ static void test_CopyFileEx(void) todo_wine ok(GetFileAttributesA(dest) == INVALID_FILE_ATTRIBUTES, "file was not deleted\n");
+ retok = CopyFileExA(source, NULL, copy_progress_cb, hfile, NULL, 0); + ok(!retok, "CopyFileExA unexpectedly succeeded\n"); + ok(GetLastError() == ERROR_PATH_NOT_FOUND, "expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError()); + retok = CopyFileExA(NULL, dest, copy_progress_cb, hfile, NULL, 0); + ok(!retok, "CopyFileExA unexpectedly succeeded\n"); + ok(GetLastError() == ERROR_PATH_NOT_FOUND, "expected ERROR_PATH_NOT_FOUND, got %d\n", GetLastError()); + ret = DeleteFileA(source); ok(ret, "DeleteFileA failed with error %d\n", GetLastError()); ret = DeleteFileA(dest);
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/msvcp120/tests/msvcp120.c | 28 +++++++++++++--------------- dlls/msvcp90/ios.c | 3 +++ 2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c index 534c0151de..70fc0c13dc 100644 --- a/dlls/msvcp120/tests/msvcp120.c +++ b/dlls/msvcp120/tests/msvcp120.c @@ -1426,19 +1426,18 @@ static void test_tr2_sys__Copy_file(void) MSVCP_bool fail_if_exists; int last_error; int last_error2; - MSVCP_bool is_todo; } tests[] = { - { "f1", "f1_copy", TRUE, ERROR_SUCCESS, ERROR_SUCCESS, FALSE }, - { "f1", "tr2_test_dir\f1_copy", TRUE, ERROR_SUCCESS, ERROR_SUCCESS, FALSE }, - { "f1", "tr2_test_dir\f1_copy", TRUE, ERROR_FILE_EXISTS, ERROR_FILE_EXISTS, FALSE }, - { "f1", "tr2_test_dir\f1_copy", FALSE, ERROR_SUCCESS, ERROR_SUCCESS, FALSE }, - { "tr2_test_dir", "f1", TRUE, ERROR_ACCESS_DENIED, ERROR_ACCESS_DENIED, FALSE }, - { "tr2_test_dir", "tr2_test_dir_copy", TRUE, ERROR_ACCESS_DENIED, ERROR_ACCESS_DENIED, FALSE }, - { NULL, "f1", TRUE, ERROR_INVALID_PARAMETER, ERROR_INVALID_PARAMETER, TRUE }, - { "f1", NULL, TRUE, ERROR_INVALID_PARAMETER, ERROR_INVALID_PARAMETER, TRUE }, - { "not_exist", "tr2_test_dir", TRUE, ERROR_FILE_NOT_FOUND, ERROR_FILE_NOT_FOUND, FALSE }, - { "f1", "not_exist_dir\f1_copy", TRUE, ERROR_PATH_NOT_FOUND, ERROR_FILE_NOT_FOUND, FALSE }, - { "f1", "tr2_test_dir", TRUE, ERROR_ACCESS_DENIED, ERROR_FILE_EXISTS, FALSE } + { "f1", "f1_copy", TRUE, ERROR_SUCCESS, ERROR_SUCCESS }, + { "f1", "tr2_test_dir\f1_copy", TRUE, ERROR_SUCCESS, ERROR_SUCCESS }, + { "f1", "tr2_test_dir\f1_copy", TRUE, ERROR_FILE_EXISTS, ERROR_FILE_EXISTS }, + { "f1", "tr2_test_dir\f1_copy", FALSE, ERROR_SUCCESS, ERROR_SUCCESS }, + { "tr2_test_dir", "f1", TRUE, ERROR_ACCESS_DENIED, ERROR_ACCESS_DENIED }, + { "tr2_test_dir", "tr2_test_dir_copy", TRUE, ERROR_ACCESS_DENIED, ERROR_ACCESS_DENIED }, + { NULL, "f1", TRUE, ERROR_INVALID_PARAMETER, ERROR_INVALID_PARAMETER }, + { "f1", NULL, TRUE, ERROR_INVALID_PARAMETER, ERROR_INVALID_PARAMETER }, + { "not_exist", "tr2_test_dir", TRUE, ERROR_FILE_NOT_FOUND, ERROR_FILE_NOT_FOUND }, + { "f1", "not_exist_dir\f1_copy", TRUE, ERROR_PATH_NOT_FOUND, ERROR_FILE_NOT_FOUND }, + { "f1", "tr2_test_dir", TRUE, ERROR_ACCESS_DENIED, ERROR_FILE_EXISTS } };
ret = p_tr2_sys__Make_dir("tr2_test_dir"); @@ -1453,9 +1452,8 @@ static void test_tr2_sys__Copy_file(void) for(i=0; i<ARRAY_SIZE(tests); i++) { errno = 0xdeadbeef; ret = p_tr2_sys__Copy_file(tests[i].source, tests[i].dest, tests[i].fail_if_exists); - todo_wine_if(tests[i].is_todo) - ok(ret == tests[i].last_error || ret == tests[i].last_error2, - "test_tr2_sys__Copy_file(): test %d expect: %d, got %d\n", i+1, tests[i].last_error, ret); + ok(ret == tests[i].last_error || ret == tests[i].last_error2, + "test_tr2_sys__Copy_file(): test %d expect: %d, got %d\n", i+1, tests[i].last_error, ret); ok(errno == 0xdeadbeef, "test_tr2_sys__Copy_file(): test %d errno expect 0xdeadbeef, got %d\n", i+1, errno); if(ret == ERROR_SUCCESS) ok(p_tr2_sys__File_size(tests[i].source) == p_tr2_sys__File_size(tests[i].dest), diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c index 743e4cadca..7f792d6ef9 100644 --- a/dlls/msvcp90/ios.c +++ b/dlls/msvcp90/ios.c @@ -14767,6 +14767,9 @@ int __cdecl tr2_sys__Copy_file(char const* source, char const* dest, MSVCP_bool { TRACE("(%s %s %x)\n", debugstr_a(source), debugstr_a(dest), fail_if_exists);
+ if(!source || !dest) + return ERROR_INVALID_PARAMETER; + if(CopyFileA(source, dest, fail_if_exists)) return ERROR_SUCCESS; return GetLastError();
Signed-off-by: Piotr Caban piotr@codeweavers.com