[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.
This commit is contained in:
Stanislav Motylkov
2026-06-13 22:54:15 +03:00
committed by GitHub
parent c78c09cfbe
commit 4e3729f06f

View File

@@ -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);