Module: wine Branch: master Commit: 49dd5577eba8b270386e4b4187ba50a6ddc2725e URL: http://source.winehq.org/git/wine.git/?a=commit;h=49dd5577eba8b270386e4b4187...
Author: Sebastian Lackner sebastian@fds-team.de Date: Fri Oct 23 04:15:52 2015 +0200
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
---
dlls/kernel32/tests/sync.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/sync.c b/dlls/kernel32/tests/sync.c index e842bf3..173793c 100644 --- a/dlls/kernel32/tests/sync.c +++ b/dlls/kernel32/tests/sync.c @@ -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);