From 4e3729f06fea6c10ac522fb572d7f6375bc4da40 Mon Sep 17 00:00:00 2001 From: Stanislav Motylkov Date: Sat, 13 Jun 2026 22:54:15 +0300 Subject: [PATCH] [KERNEL32_WINETEST] Add some ReactOS-specific tests for CopyFileEx (#9145) Cover the bug fix in PR #9133 with API tests. CORE-10271 Add them into a suitable Wine test to cover ReactOS-specific bug. The tests are confirmed to pass on Windows 2003, 7, and 10. --- modules/rostests/winetests/kernel32/file.c | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/modules/rostests/winetests/kernel32/file.c b/modules/rostests/winetests/kernel32/file.c index 88fbb3c4779..0ebb72714d9 100644 --- a/modules/rostests/winetests/kernel32/file.c +++ b/modules/rostests/winetests/kernel32/file.c @@ -1237,6 +1237,55 @@ static void test_CopyFileEx(void) ok(!retok, "CopyFileExA unexpectedly succeeded\n"); ok(GetLastError() == ERROR_PATH_NOT_FOUND, "expected ERROR_PATH_NOT_FOUND, got %ld\n", GetLastError()); +#ifdef __REACTOS__ + /* Cover ReactOS bug in CORE-10271: + * BasepCopyFileExW was handling any set flags as COPY_FILE_FAIL_IF_EXISTS. + * This affected CopyFileEx, PrivCopyFileEx, and MoveFileWithProgress */ + retok = CopyFileExA(source, dest, NULL, NULL, FALSE, 0); + ok(retok, "CopyFileExA unexpectedly failed\n"); + ok(GetLastError() == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", GetLastError()); + + /* Copy again overwriting the dest file */ + retok = CopyFileExA(source, dest, NULL, NULL, FALSE, 0); + ok(retok, "CopyFileExA unexpectedly failed\n"); + ok(GetLastError() == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", GetLastError()); + + DeleteFileA(dest); + + retok = CopyFileExA(source, dest, NULL, NULL, FALSE, COPY_FILE_FAIL_IF_EXISTS); + ok(retok, "CopyFileExA unexpectedly failed\n"); + ok(GetLastError() == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", GetLastError()); + + retok = CopyFileExA(source, dest, NULL, NULL, FALSE, COPY_FILE_FAIL_IF_EXISTS); + ok(!retok, "CopyFileExA unexpectedly succeeded\n"); + ok(GetLastError() == ERROR_FILE_EXISTS, "expected ERROR_FILE_EXISTS, got %ld\n", GetLastError()); + + retok = CopyFileExA(source, dest, NULL, NULL, FALSE, COPY_FILE_RESTARTABLE); + ok(retok, "CopyFileExA unexpectedly failed\n"); + ok(GetLastError() == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", GetLastError()); + + retok = CopyFileExA(source, dest, NULL, NULL, FALSE, COPY_FILE_ALLOW_DECRYPTED_DESTINATION); + ok(retok, "CopyFileExA unexpectedly failed\n"); + ok(GetLastError() == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", GetLastError()); + + retok = CopyFileExA(source, dest, NULL, NULL, FALSE, COPY_FILE_RESTARTABLE | COPY_FILE_ALLOW_DECRYPTED_DESTINATION); + ok(retok, "CopyFileExA unexpectedly failed\n"); + ok(GetLastError() == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", GetLastError()); + + retok = CopyFileExA(source, dest, NULL, NULL, FALSE, COPY_FILE_FAIL_IF_EXISTS | COPY_FILE_RESTARTABLE); + ok(!retok, "CopyFileExA unexpectedly succeeded\n"); + ok(GetLastError() == ERROR_FILE_EXISTS, "expected ERROR_FILE_EXISTS, got %ld\n", GetLastError()); + + retok = CopyFileExA(source, dest, NULL, NULL, FALSE, COPY_FILE_FAIL_IF_EXISTS | COPY_FILE_ALLOW_DECRYPTED_DESTINATION); + ok(!retok, "CopyFileExA unexpectedly succeeded\n"); + ok(GetLastError() == ERROR_FILE_EXISTS, "expected ERROR_FILE_EXISTS, got %ld\n", GetLastError()); + + retok = CopyFileExA(source, dest, NULL, NULL, FALSE, COPY_FILE_FAIL_IF_EXISTS | COPY_FILE_RESTARTABLE | COPY_FILE_ALLOW_DECRYPTED_DESTINATION); + ok(!retok, "CopyFileExA unexpectedly succeeded\n"); + ok(GetLastError() == ERROR_FILE_EXISTS, "expected ERROR_FILE_EXISTS, got %ld\n", GetLastError()); + + DeleteFileA(dest); +#endif ret = DeleteFileA(source); ok(ret, "DeleteFileA failed with error %ld\n", GetLastError()); ret = DeleteFileA(dest);