Commit 85386c2c authored by André Hentschel's avatar André Hentschel Committed by Alexandre Julliard

kernel32/tests: Don't test function directly when reporting GetLastError().

parent 13b0452c
......@@ -1145,6 +1145,7 @@ static void run_child_process(void)
STARTUPINFO si = { 0 };
HANDLE file;
FILETIME now;
BOOL ret;
GetModuleFileNameA(NULL, path, MAX_PATH);
strcat(path, ".manifest");
......@@ -1165,8 +1166,8 @@ static void run_child_process(void)
CloseHandle(file);
}
sprintf(cmdline, "\"%s\" %s manifest1", argv[0], argv[1]);
ok(CreateProcess(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL,
&si, &pi) != 0, "Could not create process: %u\n", GetLastError());
ret = CreateProcess(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
ok(ret, "Could not create process: %u\n", GetLastError());
winetest_wait_child_process( pi.hProcess );
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
......
......@@ -1627,8 +1627,10 @@ static void test_WaitBreak(HANDLE hcom)
trace("overlapped WriteCommEvent returned.\n");
if (!success && (err == ERROR_IO_PENDING))
ok(WaitForSingleObjectEx(hComPortEvent, TIMEOUT, TRUE) == 0,
"wait hComPortEvent res %d\n", GetLastError());
{
success = WaitForSingleObjectEx(hComPortEvent, TIMEOUT, TRUE);
ok(!success, "wait hComPortEvent res %d\n", GetLastError());
}
success = GetOverlappedResult(hcom, &overlapped, &written, FALSE);
err = GetLastError();
after1 = GetTickCount();
......
......@@ -267,6 +267,7 @@ static void doDebugger(int argc, char** argv)
static void crash_and_debug(HKEY hkey, const char* argv0, const char* dbgtasks)
{
static BOOL skip_crash_and_debug = FALSE;
BOOL bRet;
DWORD ret;
HANDLE start_event, done_event;
char* cmd;
......@@ -327,7 +328,8 @@ static void crash_and_debug(HKEY hkey, const char* argv0, const char* dbgtasks)
}
#endif
ok(wait_code == WAIT_OBJECT_0, "Timed out waiting for the child to crash\n");
ok(GetExitCodeProcess(info.hProcess, &exit_code), "GetExitCodeProcess failed: err=%d\n", GetLastError());
bRet = GetExitCodeProcess(info.hProcess, &exit_code);
ok(bRet, "GetExitCodeProcess failed: err=%d\n", GetLastError());
if (strstr(dbgtasks, "code2"))
{
/* If, after attaching to the debuggee, the debugger exits without
......@@ -381,6 +383,7 @@ static void crash_and_debug(HKEY hkey, const char* argv0, const char* dbgtasks)
static void crash_and_winedbg(HKEY hkey, const char* argv0)
{
BOOL bRet;
DWORD ret;
char* cmd;
PROCESS_INFORMATION info;
......@@ -404,7 +407,8 @@ static void crash_and_winedbg(HKEY hkey, const char* argv0)
trace("waiting for child exit...\n");
ok(WaitForSingleObject(info.hProcess, 60000) == WAIT_OBJECT_0, "Timed out waiting for the child to crash\n");
ok(GetExitCodeProcess(info.hProcess, &exit_code), "GetExitCodeProcess failed: err=%d\n", GetLastError());
bRet = GetExitCodeProcess(info.hProcess, &exit_code);
ok(bRet, "GetExitCodeProcess failed: err=%d\n", GetLastError());
ok(exit_code == STATUS_ACCESS_VIOLATION, "exit code = %08x\n", exit_code);
CloseHandle(info.hProcess);
}
......
......@@ -101,7 +101,8 @@ static void test_ConvertFiberToThread(void)
{
if (pConvertFiberToThread)
{
ok(pConvertFiberToThread() , "ConvertFiberToThread failed with error %d\n", GetLastError());
BOOL ret = pConvertFiberToThread();
ok(ret, "ConvertFiberToThread failed with error %d\n", GetLastError());
}
else
{
......
......@@ -279,8 +279,8 @@ static void test_Loader(void)
}
SetLastError(0xdeadbeef);
ok(WriteFile(hfile, td[i].dos_header, td[i].size_of_dos_header, &dummy, NULL),
"WriteFile error %d\n", GetLastError());
ret = WriteFile(hfile, td[i].dos_header, td[i].size_of_dos_header, &dummy, NULL);
ok(ret, "WriteFile error %d\n", GetLastError());
nt_header.FileHeader.NumberOfSections = td[i].number_of_sections;
nt_header.FileHeader.SizeOfOptionalHeader = td[i].size_of_optional_header;
......@@ -290,23 +290,23 @@ static void test_Loader(void)
nt_header.OptionalHeader.SizeOfImage = td[i].size_of_image;
nt_header.OptionalHeader.SizeOfHeaders = td[i].size_of_headers;
SetLastError(0xdeadbeef);
ok(WriteFile(hfile, &nt_header, sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER), &dummy, NULL),
"WriteFile error %d\n", GetLastError());
ret = WriteFile(hfile, &nt_header, sizeof(DWORD) + sizeof(IMAGE_FILE_HEADER), &dummy, NULL);
ok(ret, "WriteFile error %d\n", GetLastError());
if (nt_header.FileHeader.SizeOfOptionalHeader)
{
SetLastError(0xdeadbeef);
ok(WriteFile(hfile, &nt_header.OptionalHeader,
ret = WriteFile(hfile, &nt_header.OptionalHeader,
min(nt_header.FileHeader.SizeOfOptionalHeader, sizeof(IMAGE_OPTIONAL_HEADER)),
&dummy, NULL),
"WriteFile error %d\n", GetLastError());
&dummy, NULL);
ok(ret, "WriteFile error %d\n", GetLastError());
if (nt_header.FileHeader.SizeOfOptionalHeader > sizeof(IMAGE_OPTIONAL_HEADER))
{
file_align = nt_header.FileHeader.SizeOfOptionalHeader - sizeof(IMAGE_OPTIONAL_HEADER);
assert(file_align < sizeof(filler));
SetLastError(0xdeadbeef);
ok(WriteFile(hfile, filler, file_align, &dummy, NULL),
"WriteFile error %d\n", GetLastError());
ret = WriteFile(hfile, filler, file_align, &dummy, NULL);
ok(ret, "WriteFile error %d\n", GetLastError());
}
}
......@@ -327,13 +327,13 @@ static void test_Loader(void)
}
SetLastError(0xdeadbeef);
ok(WriteFile(hfile, &section, sizeof(section), &dummy, NULL),
"WriteFile error %d\n", GetLastError());
ret = WriteFile(hfile, &section, sizeof(section), &dummy, NULL);
ok(ret, "WriteFile error %d\n", GetLastError());
/* section data */
SetLastError(0xdeadbeef);
ok(WriteFile(hfile, section_data, sizeof(section_data), &dummy, NULL),
"WriteFile error %d\n", GetLastError());
ret = WriteFile(hfile, section_data, sizeof(section_data), &dummy, NULL);
ok(ret, "WriteFile error %d\n", GetLastError());
}
file_size = GetFileSize(hfile, NULL);
......@@ -500,7 +500,8 @@ static void test_Loader(void)
}
SetLastError(0xdeadbeef);
ok(DeleteFile(dll_name), "DeleteFile error %d\n", GetLastError());
ret = DeleteFile(dll_name);
ok(ret, "DeleteFile error %d\n", GetLastError());
}
}
......
......@@ -221,6 +221,7 @@ static void testLoadLibraryEx(void)
CHAR path[MAX_PATH];
HMODULE hmodule;
HANDLE hfile;
BOOL ret;
hfile = CreateFileA("testfile.dll", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
......@@ -367,13 +368,11 @@ static void testLoadLibraryEx(void)
ok(hmodule != 0, "Expected valid module handle\n");
SetLastError(0xdeadbeef);
ok(FreeLibrary(hmodule),
"Expected to be able to free the module, failed with %d\n",
GetLastError());
ret = FreeLibrary(hmodule);
ok(ret, "Expected to be able to free the module, failed with %d\n", GetLastError());
SetLastError(0xdeadbeef);
ok(!FreeLibrary(hmodule),
"Unexpected ability to free the module, failed with %d\n",
GetLastError());
ret = FreeLibrary(hmodule);
ok(!ret, "Unexpected ability to free the module, failed with %d\n", GetLastError());
CloseHandle(hmodule);
......
......@@ -50,6 +50,7 @@ static void test_CreateNamedPipe(int pipemode)
DWORD readden;
DWORD avail;
DWORD lpmode;
BOOL ret;
if (pipemode == PIPE_TYPE_BYTE)
trace("test_CreateNamedPipe starting in byte mode\n");
......@@ -86,12 +87,14 @@ static void test_CreateNamedPipe(int pipemode)
/* lpSecurityAttrib */ NULL);
ok(hnp != INVALID_HANDLE_VALUE, "CreateNamedPipe failed\n");
ok(WaitNamedPipeA(PIPENAME, 2000), "WaitNamedPipe failed (%d)\n", GetLastError());
ret = WaitNamedPipeA(PIPENAME, 2000);
ok(ret, "WaitNamedPipe failed (%d)\n", GetLastError());
hFile = CreateFileA(PIPENAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
ok(hFile != INVALID_HANDLE_VALUE, "CreateFile failed (%d)\n", GetLastError());
ok(!WaitNamedPipeA(PIPENAME, 1000), "WaitNamedPipe succeeded\n");
ok(GetLastError() == ERROR_SEM_TIMEOUT, "wrong error %u\n", GetLastError());
/* don't try to do i/o if one side couldn't be opened, as it hangs */
......@@ -642,6 +645,7 @@ static DWORD CALLBACK serverThreadMain4(LPVOID arg)
{
int i;
HANDLE hcompletion;
BOOL ret;
trace("serverThreadMain4\n");
/* Set up a simple echo server */
......@@ -738,8 +742,10 @@ static DWORD CALLBACK serverThreadMain4(LPVOID arg)
ok(success, "DisconnectNamedPipe failed, err %u\n", GetLastError());
}
ok(CloseHandle(hnp), "CloseHandle named pipe failed, err=%i\n", GetLastError());
ok(CloseHandle(hcompletion), "CloseHandle completion failed, err=%i\n", GetLastError());
ret = CloseHandle(hnp);
ok(ret, "CloseHandle named pipe failed, err=%i\n", GetLastError());
ret = CloseHandle(hcompletion);
ok(ret, "CloseHandle completion failed, err=%i\n", GetLastError());
return 0;
}
......
......@@ -1518,6 +1518,7 @@ static void test_OpenProcess(void)
void *addr1;
MEMORY_BASIC_INFORMATION info;
SIZE_T dummy, read_bytes;
BOOL ret;
/* not exported in all windows versions */
if ((!pVirtualAllocEx) || (!pVirtualFreeEx)) {
......@@ -1542,8 +1543,8 @@ static void test_OpenProcess(void)
read_bytes = 0xdeadbeef;
SetLastError(0xdeadbeef);
ok(ReadProcessMemory(hproc, test_OpenProcess, &dummy, sizeof(dummy), &read_bytes),
"ReadProcessMemory error %d\n", GetLastError());
ret = ReadProcessMemory(hproc, test_OpenProcess, &dummy, sizeof(dummy), &read_bytes);
ok(ret, "ReadProcessMemory error %d\n", GetLastError());
ok(read_bytes == sizeof(dummy), "wrong read bytes %ld\n", read_bytes);
CloseHandle(hproc);
......@@ -1573,8 +1574,8 @@ static void test_OpenProcess(void)
hproc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, GetCurrentProcessId());
memset(&info, 0xcc, sizeof(info));
ok(VirtualQueryEx(hproc, addr1, &info, sizeof(info)) == sizeof(info),
"VirtualQueryEx error %d\n", GetLastError());
read_bytes = VirtualQueryEx(hproc, addr1, &info, sizeof(info));
ok(read_bytes == sizeof(info), "VirtualQueryEx error %d\n", GetLastError());
ok(info.BaseAddress == addr1, "%p != %p\n", info.BaseAddress, addr1);
ok(info.AllocationBase == addr1, "%p != %p\n", info.AllocationBase, addr1);
......
......@@ -71,14 +71,16 @@ static HANDLE create_target_process(const char *arg)
char **argv;
char cmdline[MAX_PATH];
PROCESS_INFORMATION pi;
BOOL ret;
STARTUPINFO si = { 0 };
si.cb = sizeof(si);
winetest_get_mainargs( &argv );
sprintf(cmdline, "%s %s %s", argv[0], argv[1], arg);
ok(CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL,
&si, &pi) != 0, "error: %u\n", GetLastError());
ok(CloseHandle(pi.hThread) != 0, "error %u\n", GetLastError());
ret = CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
ok(ret, "error: %u\n", GetLastError());
ret = CloseHandle(pi.hThread);
ok(ret, "error %u\n", GetLastError());
return pi.hProcess;
}
......@@ -368,6 +370,7 @@ static VOID test_CreateThread_basic(void)
DWORD i,j;
DWORD GLE, ret;
DWORD tid;
BOOL bRet;
/* lstrlenA contains an exception handler so this makes sure exceptions work in the main thread */
ok( lstrlenA( (char *)0xdeadbeef ) == 0, "lstrlenA: unexpected success\n" );
......@@ -423,7 +426,8 @@ static VOID test_CreateThread_basic(void)
}
SetLastError(0xCAFEF00D);
ok(TlsFree(tlsIndex)!=0,"TlsFree failed: %08x\n", GetLastError());
bRet = TlsFree(tlsIndex);
ok(bRet, "TlsFree failed: %08x\n", GetLastError());
ok(GetLastError()==0xCAFEF00D,
"GetLastError: expected 0xCAFEF00D, got %08x\n", GetLastError());
......
......@@ -46,14 +46,16 @@ static HANDLE create_target_process(const char *arg)
char **argv;
char cmdline[MAX_PATH];
PROCESS_INFORMATION pi;
BOOL ret;
STARTUPINFO si = { 0 };
si.cb = sizeof(si);
winetest_get_mainargs( &argv );
sprintf(cmdline, "%s %s %s", argv[0], argv[1], arg);
ok(CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL,
&si, &pi) != 0, "error: %u\n", GetLastError());
ok(CloseHandle(pi.hThread) != 0, "error %u\n", GetLastError());
ret = CreateProcess(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
ok(ret, "error: %u\n", GetLastError());
ret = CloseHandle(pi.hThread);
ok(ret, "error %u\n", GetLastError());
return pi.hProcess;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment