kernel32/tests: Add test to show that multiple user APCs are processed at once.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ae8be1f84c
commit
49dd5577eb
|
@ -2333,6 +2333,13 @@ static DWORD WINAPI alertable_wait_thread(void *param)
|
|||
todo_wine
|
||||
ok(status == STATUS_WAIT_0, "expected STATUS_WAIT_0, got %08x\n", status);
|
||||
|
||||
ReleaseSemaphore(semaphores[0], 1, NULL);
|
||||
timeout.QuadPart = -10000000;
|
||||
status = pNtWaitForMultipleObjects(1, &semaphores[1], FALSE, TRUE, &timeout);
|
||||
ok(status == STATUS_USER_APC, "expected STATUS_USER_APC, got %08x\n", status);
|
||||
result = WaitForSingleObject(semaphores[0], 0);
|
||||
ok(result == WAIT_TIMEOUT, "expected WAIT_TIMEOUT, got %u\n", result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2342,12 +2349,21 @@ static void CALLBACK alertable_wait_apc(ULONG_PTR userdata)
|
|||
ReleaseSemaphore(semaphores[1], 1, NULL);
|
||||
}
|
||||
|
||||
static void CALLBACK alertable_wait_apc2(ULONG_PTR userdata)
|
||||
{
|
||||
HANDLE *semaphores = (void *)userdata;
|
||||
DWORD result;
|
||||
|
||||
result = WaitForSingleObject(semaphores[0], 1000);
|
||||
ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
|
||||
}
|
||||
|
||||
static void test_alertable_wait(void)
|
||||
{
|
||||
HANDLE thread, semaphores[2];
|
||||
DWORD result;
|
||||
|
||||
semaphores[0] = CreateSemaphoreW(NULL, 0, 1, NULL);
|
||||
semaphores[0] = CreateSemaphoreW(NULL, 0, 2, NULL);
|
||||
ok(semaphores[0] != NULL, "CreateSemaphore failed with %u\n", GetLastError());
|
||||
semaphores[1] = CreateSemaphoreW(NULL, 0, 1, NULL);
|
||||
ok(semaphores[1] != NULL, "CreateSemaphore failed with %u\n", GetLastError());
|
||||
|
@ -2366,6 +2382,15 @@ static void test_alertable_wait(void)
|
|||
result = QueueUserAPC(alertable_wait_apc, thread, (ULONG_PTR)semaphores);
|
||||
ok(result != 0, "QueueUserAPC failed with %u\n", GetLastError());
|
||||
|
||||
result = WaitForSingleObject(semaphores[0], 1000);
|
||||
ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
|
||||
Sleep(100); /* ensure the thread is blocking in NtWaitForMultipleObjects */
|
||||
result = QueueUserAPC(alertable_wait_apc2, thread, (ULONG_PTR)semaphores);
|
||||
ok(result != 0, "QueueUserAPC failed with %u\n", GetLastError());
|
||||
result = QueueUserAPC(alertable_wait_apc2, thread, (ULONG_PTR)semaphores);
|
||||
ok(result != 0, "QueueUserAPC failed with %u\n", GetLastError());
|
||||
ReleaseSemaphore(semaphores[0], 2, NULL);
|
||||
|
||||
result = WaitForSingleObject(thread, 1000);
|
||||
ok(result == WAIT_OBJECT_0, "expected WAIT_OBJECT_0, got %u\n", result);
|
||||
CloseHandle(thread);
|
||||
|
|
Loading…
Reference in New Issue