Sebastian Lackner : ntdll/tests: Add basic tests for RtlQueueWorkItem.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jul 28 13:30:06 CDT 2015
Module: wine
Branch: master
Commit: c774a8c3ae89959be5798554cb60cb52dbfe1723
URL: http://source.winehq.org/git/wine.git/?a=commit;h=c774a8c3ae89959be5798554cb60cb52dbfe1723
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Sun Jul 26 23:23:57 2015 +0200
ntdll/tests: Add basic tests for RtlQueueWorkItem.
---
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;
More information about the wine-cvs
mailing list