From: YongHao Hu Subject: kernel32/tests: Add test of LastError in path.c. Message-Id: <55C32BE8.5070402@gmail.com> Date: Thu, 6 Aug 2015 17:42:00 +0800 Add test of the bug Incorrect GetLastError error of RemoveDirectoryA and CreateDirectory[1]. [1]: https://bugs.winehq.org/show_bug.cgi?id=38772 --- dlls/kernel32/tests/path.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c index f8dfdc8..a6fcfae 100644 --- a/dlls/kernel32/tests/path.c +++ b/dlls/kernel32/tests/path.c @@ -2205,6 +2205,36 @@ static void test_CheckNameLegalDOS8Dot3(void) } } +static void test_CheckLastError(void) +{ + HANDLE file; + + SetLastError(0xdeadbeef); + RemoveDirectoryA("Z:\\not_exist"); + todo_wine ok(GetLastError() == ERROR_PATH_NOT_FOUND, "test_CheckLastError(): GetLastError expect ERROR_PATH_NOT_FOUND got %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + RemoveDirectoryA("not_exist"); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "test_CheckLastError(): GetLastError expect ERROR_FILE_NOT_FOUND got %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + CopyFileA(NULL, "f1", TRUE); + ok(GetLastError() == ERROR_PATH_NOT_FOUND, "test_CheckLastError(): GetLastError expect ERROR_PATH_NOT_FOUND got %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + CopyFileA("f1", NULL, TRUE); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "test_CheckLastError(): GetLastError expect ERROR_FILE_NOT_FOUND got %u\n", GetLastError()); + + SetLastError(0xdeadbeef); + file = CreateNamedPipeA("\\\\.\\PiPe\\tests_pipe.c", + PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_WAIT, 2, 1024, 1024, + NMPWAIT_USE_DEFAULT_WAIT, NULL); + ok(file != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n"); + GetFileAttributesA("\\\\.\\PiPe\\tests_pipe.c"); + todo_wine ok(GetLastError()==ERROR_SUCCESS || GetLastError()==0xdeadbeef, "test_CheckLastError(): GetLastError expect ERROR_SUCCESS or 0xdeadbeef got %u\n", GetLastError()); + ok(CloseHandle(file), "CloseHandle\n"); +} + START_TEST(path) { CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive; @@ -2238,4 +2268,5 @@ START_TEST(path) test_GetFullPathNameA(); test_GetFullPathNameW(); test_CheckNameLegalDOS8Dot3(); + test_CheckLastError(); }