[KERNEL32_WINETEST]

sync kernel32_winetest to wine 1.1.40

svn path=/trunk/; revision=45938
This commit is contained in:
Christoph von Wittich 2010-03-06 13:36:22 +00:00
parent a609bd9f70
commit ad6f164929
5 changed files with 136 additions and 6 deletions

View file

@ -79,6 +79,7 @@ static DWORD FinishNotificationThread(HANDLE thread)
ok(status == WAIT_OBJECT_0, "WaitForSingleObject status %d error %d\n", status, GetLastError());
ok(GetExitCodeThread(thread, &exitcode), "Could not retrieve thread exit code\n");
CloseHandle(thread);
return exitcode;
}

View file

@ -31,6 +31,14 @@
#define STATUS_DEBUGGER_INACTIVE ((NTSTATUS) 0xC0000354)
#endif
#ifdef __GNUC__
#define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
#else
#define PRINTF_ATTR(fmt,args)
#endif
#define child_ok (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_child_ok
static int myARGC;
static char** myARGV;
@ -38,6 +46,18 @@ static BOOL (WINAPI *pCheckRemoteDebuggerPresent)(HANDLE,PBOOL);
static BOOL (WINAPI *pDebugActiveProcessStop)(DWORD);
static BOOL (WINAPI *pDebugSetProcessKillOnExit)(BOOL);
static LONG child_failures;
static void PRINTF_ATTR(2, 3) test_child_ok(int condition, const char *msg, ...)
{
va_list valist;
va_start(valist, msg);
winetest_vok(condition, msg, valist);
va_end(valist);
if (!condition) ++child_failures;
}
/* Copied from the process test */
static void get_file_name(char* buf)
{
@ -468,6 +488,94 @@ static void test_RemoteDebugger(void)
"expected error ERROR_INVALID_PARAMETER, got %d/%x\n",GetLastError(), GetLastError());
}
struct child_blackbox
{
LONG failures;
};
static void doChild(int argc, char **argv)
{
struct child_blackbox blackbox;
const char *blackbox_file;
HANDLE parent;
DWORD ppid;
BOOL ret;
blackbox_file = argv[4];
sscanf(argv[3], "%08x", &ppid);
parent = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ppid);
child_ok(!!parent, "OpenProcess failed, last error %#x.\n", GetLastError());
ret = DebugActiveProcess(ppid);
child_ok(ret, "DebugActiveProcess failed, last error %#x.\n", GetLastError());
ret = pDebugActiveProcessStop(ppid);
child_ok(ret, "DebugActiveProcessStop failed, last error %#x.\n", GetLastError());
ret = CloseHandle(parent);
child_ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
blackbox.failures = child_failures;
save_blackbox(blackbox_file, &blackbox, sizeof(blackbox));
}
static void test_debug_loop(int argc, char **argv)
{
const char *arguments = " debugger child ";
struct child_blackbox blackbox;
char blackbox_file[MAX_PATH];
PROCESS_INFORMATION pi;
STARTUPINFOA si;
DWORD pid;
char *cmd;
BOOL ret;
if (!pDebugActiveProcessStop)
{
win_skip("DebugActiveProcessStop not available, skipping test.\n");
return;
}
pid = GetCurrentProcessId();
get_file_name(blackbox_file);
cmd = HeapAlloc(GetProcessHeap(), 0, strlen(argv[0]) + strlen(arguments) + strlen(blackbox_file) + 10);
sprintf(cmd, "%s%s%08x %s", argv[0], arguments, pid, blackbox_file);
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
ret = CreateProcessA(NULL, cmd, NULL, NULL, FALSE, DEBUG_PROCESS, NULL, NULL, &si, &pi);
ok(ret, "CreateProcess failed, last error %#x.\n", GetLastError());
HeapFree(GetProcessHeap(), 0, cmd);
for (;;)
{
DEBUG_EVENT ev;
ret = WaitForDebugEvent(&ev, INFINITE);
ok(ret, "WaitForDebugEvent failed, last error %#x.\n", GetLastError());
if (!ret) break;
if (ev.dwDebugEventCode == EXIT_PROCESS_DEBUG_EVENT) break;
ret = ContinueDebugEvent(ev.dwProcessId, ev.dwThreadId, DBG_CONTINUE);
ok(ret, "ContinueDebugEvent failed, last error %#x.\n", GetLastError());
if (!ret) break;
}
ret = CloseHandle(pi.hThread);
ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
ret = CloseHandle(pi.hProcess);
ok(ret, "CloseHandle failed, last error %#x.\n", GetLastError());
load_blackbox(blackbox_file, &blackbox, sizeof(blackbox));
ok(!blackbox.failures, "Got %d failures from child process.\n", blackbox.failures);
ret = DeleteFileA(blackbox_file);
ok(ret, "DeleteFileA failed, last error %#x.\n", GetLastError());
}
START_TEST(debugger)
{
HMODULE hdll;
@ -486,9 +594,14 @@ START_TEST(debugger)
{
doDebugger(myARGC, myARGV);
}
else if (myARGC >= 5 && !strcmp(myARGV[2], "child"))
{
doChild(myARGC, myARGV);
}
else
{
test_ExitCode();
test_RemoteDebugger();
test_debug_loop(myARGC, myARGV);
}
}

View file

@ -1602,12 +1602,12 @@ static void test_LockFile(void)
/* zero-byte lock */
ok( LockFile( handle, 100, 0, 0, 0 ), "LockFile 100,0 failed\n" );
limited_LockFile || ok( !LockFile( handle, 98, 0, 4, 0 ), "LockFile 98,4 succeeded\n" );
if (!limited_LockFile) ok( !LockFile( handle, 98, 0, 4, 0 ), "LockFile 98,4 succeeded\n" );
ok( LockFile( handle, 90, 0, 10, 0 ), "LockFile 90,10 failed\n" );
limited_LockFile || ok( !LockFile( handle, 100, 0, 10, 0 ), "LockFile 100,10 failed\n" );
if (!limited_LockFile) ok( !LockFile( handle, 100, 0, 10, 0 ), "LockFile 100,10 failed\n" );
ok( UnlockFile( handle, 90, 0, 10, 0 ), "UnlockFile 90,10 failed\n" );
!ok( UnlockFile( handle, 100, 0, 10, 0 ), "UnlockFile 100,10 failed\n" );
ok( !UnlockFile( handle, 100, 0, 10, 0 ), "UnlockFile 100,10 succeeded\n" );
ok( UnlockFile( handle, 100, 0, 0, 0 ), "UnlockFile 100,0 failed\n" );

View file

@ -709,6 +709,7 @@ static void test_message_from_hmodule(void)
ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
ok(error == ERROR_RESOURCE_LANG_NOT_FOUND ||
error == ERROR_MR_MID_NOT_FOUND ||
error == ERROR_MUI_FILE_NOT_FOUND ||
error == ERROR_MUI_FILE_NOT_LOADED,
"last error %u\n", error);
@ -719,7 +720,8 @@ static void test_message_from_hmodule(void)
ok(ret == 0, "FormatMessageA returned %u instead of 0\n", ret);
ok(error == ERROR_RESOURCE_LANG_NOT_FOUND ||
error == ERROR_MR_MID_NOT_FOUND ||
error == ERROR_MUI_FILE_NOT_FOUND,
error == ERROR_MUI_FILE_NOT_FOUND ||
error == ERROR_MUI_FILE_NOT_LOADED,
"last error %u\n", error);
}

View file

@ -421,7 +421,17 @@ static VOID test_CreateThread_basic(void)
"Thread did not execute successfully\n");
ok(CloseHandle(thread[i])!=0,"CloseHandle failed\n");
}
ok(TlsFree(tlsIndex)!=0,"TlsFree failed\n");
SetLastError(0xCAFEF00D);
ok(TlsFree(tlsIndex)!=0,"TlsFree failed: %08x\n", GetLastError());
ok(GetLastError()==0xCAFEF00D,
"GetLastError: expected 0xCAFEF00D, got %08x\n", GetLastError());
/* Test freeing an already freed TLS index */
SetLastError(0xCAFEF00D);
ok(TlsFree(tlsIndex)==0,"TlsFree succeeded\n");
ok(GetLastError()==ERROR_INVALID_PARAMETER,
"GetLastError: expected ERROR_INVALID_PARAMETER, got %08x\n", GetLastError());
/* Test how passing NULL as a pointer to threadid works */
SetLastError(0xFACEaBAD);
@ -780,7 +790,7 @@ static VOID test_GetThreadTimes(void)
static VOID test_thread_processor(void)
{
HANDLE curthread,curproc;
DWORD_PTR processMask,systemMask;
DWORD_PTR processMask,systemMask,retMask;
SYSTEM_INFO sysInfo;
int error=0;
BOOL is_wow64;
@ -803,6 +813,10 @@ static VOID test_thread_processor(void)
"SetThreadAffinityMask failed\n");
ok(SetThreadAffinityMask(curthread,processMask+1)==0,
"SetThreadAffinityMask passed for an illegal processor\n");
/* NOTE: Pre-Vista does not recognize the "all processors" flag (all bits set) */
retMask = SetThreadAffinityMask(curthread,~0UL);
ok(broken(retMask==0) || retMask==processMask,
"SetThreadAffinityMask(thread,-1) failed to request all processors.\n");
/* NOTE: This only works on WinNT/2000/XP) */
if (pSetThreadIdealProcessor) {
SetLastError(0xdeadbeef);