[1/2] ntdll/tests: Add basic tests for RtlQueueWorkItem.

Sebastian Lackner sebastian at fds-team.de
Sun Jul 26 16:23:57 CDT 2015


---
 dlls/ntdll/tests/threadpool.c |   47 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/dlls/ntdll/tests/threadpool.c b/dlls/ntdll/tests/threadpool.c
index c69902b..7be3f0d 100644
--- a/dlls/ntdll/tests/threadpool.c
+++ b/dlls/ntdll/tests/threadpool.c
@@ -98,6 +98,51 @@ static BOOL init_threadpool(void)
 #undef NTDLL_GET_PROC
 
 
+static DWORD CALLBACK rtl_work_cb(void *userdata)
+{
+    HANDLE semaphore = userdata;
+    trace("Running rtl_work callback\n");
+    ReleaseSemaphore(semaphore, 1, NULL);
+    return 0;
+}
+
+static void test_RtlQueueWorkItem(void)
+{
+    HANDLE semaphore;
+    NTSTATUS status;
+    DWORD result;
+
+    semaphore = CreateSemaphoreA(NULL, 0, 1, NULL);
+    ok(semaphore != NULL, "CreateSemaphoreA failed %u\n", GetLastError());
+
+    status = RtlQueueWorkItem(rtl_work_cb, semaphore, WT_EXECUTEDEFAULT);
+    ok(!status, "RtlQueueWorkItem failed with status %x\n", status);
+    result = WaitForSingleObject(semaphore, 1000);
+    ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
+
+    status = RtlQueueWorkItem(rtl_work_cb, semaphore, WT_EXECUTEINIOTHREAD);
+    ok(!status, "RtlQueueWorkItem failed with status %x\n", status);
+    result = WaitForSingleObject(semaphore, 1000);
+    ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
+
+    status = RtlQueueWorkItem(rtl_work_cb, semaphore, WT_EXECUTEINPERSISTENTTHREAD);
+    ok(!status, "RtlQueueWorkItem failed with status %x\n", status);
+    result = WaitForSingleObject(semaphore, 1000);
+    ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
+
+    status = RtlQueueWorkItem(rtl_work_cb, semaphore, WT_EXECUTELONGFUNCTION);
+    ok(!status, "RtlQueueWorkItem failed with status %x\n", status);
+    result = WaitForSingleObject(semaphore, 1000);
+    ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
+
+    status = RtlQueueWorkItem(rtl_work_cb, semaphore, WT_TRANSFER_IMPERSONATION);
+    ok(!status, "RtlQueueWorkItem failed with status %x\n", status);
+    result = WaitForSingleObject(semaphore, 1000);
+    ok(result == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", result);
+
+    CloseHandle(semaphore);
+}
+
 static void CALLBACK simple_cb(TP_CALLBACK_INSTANCE *instance, void *userdata)
 {
     HANDLE semaphore = userdata;
@@ -1292,6 +1337,8 @@ static void test_tp_multi_wait(void)
 
 START_TEST(threadpool)
 {
+    test_RtlQueueWorkItem();
+
     if (!init_threadpool())
         return;
 
-- 
2.4.5



More information about the wine-patches mailing list