Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
17cd2a8b
Commit
17cd2a8b
authored
Jul 01, 2015
by
Sebastian Lackner
Committed by
Alexandre Julliard
Jul 01, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll/tests: Add basic tests for threadpool work items.
parent
e4c38f6b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
threadpool.c
dlls/ntdll/tests/threadpool.c
+59
-0
No files found.
dlls/ntdll/tests/threadpool.c
View file @
17cd2a8b
...
@@ -23,10 +23,14 @@
...
@@ -23,10 +23,14 @@
static
HMODULE
hntdll
=
0
;
static
HMODULE
hntdll
=
0
;
static
NTSTATUS
(
WINAPI
*
pTpAllocCleanupGroup
)(
TP_CLEANUP_GROUP
**
);
static
NTSTATUS
(
WINAPI
*
pTpAllocCleanupGroup
)(
TP_CLEANUP_GROUP
**
);
static
NTSTATUS
(
WINAPI
*
pTpAllocPool
)(
TP_POOL
**
,
PVOID
);
static
NTSTATUS
(
WINAPI
*
pTpAllocPool
)(
TP_POOL
**
,
PVOID
);
static
NTSTATUS
(
WINAPI
*
pTpAllocWork
)(
TP_WORK
**
,
PTP_WORK_CALLBACK
,
PVOID
,
TP_CALLBACK_ENVIRON
*
);
static
VOID
(
WINAPI
*
pTpPostWork
)(
TP_WORK
*
);
static
VOID
(
WINAPI
*
pTpReleaseCleanupGroup
)(
TP_CLEANUP_GROUP
*
);
static
VOID
(
WINAPI
*
pTpReleaseCleanupGroup
)(
TP_CLEANUP_GROUP
*
);
static
VOID
(
WINAPI
*
pTpReleaseCleanupGroupMembers
)(
TP_CLEANUP_GROUP
*
,
BOOL
,
PVOID
);
static
VOID
(
WINAPI
*
pTpReleaseCleanupGroupMembers
)(
TP_CLEANUP_GROUP
*
,
BOOL
,
PVOID
);
static
VOID
(
WINAPI
*
pTpReleasePool
)(
TP_POOL
*
);
static
VOID
(
WINAPI
*
pTpReleasePool
)(
TP_POOL
*
);
static
VOID
(
WINAPI
*
pTpReleaseWork
)(
TP_WORK
*
);
static
NTSTATUS
(
WINAPI
*
pTpSimpleTryPost
)(
PTP_SIMPLE_CALLBACK
,
PVOID
,
TP_CALLBACK_ENVIRON
*
);
static
NTSTATUS
(
WINAPI
*
pTpSimpleTryPost
)(
PTP_SIMPLE_CALLBACK
,
PVOID
,
TP_CALLBACK_ENVIRON
*
);
static
VOID
(
WINAPI
*
pTpWaitForWork
)(
TP_WORK
*
,
BOOL
);
#define NTDLL_GET_PROC(func) \
#define NTDLL_GET_PROC(func) \
do \
do \
...
@@ -47,10 +51,14 @@ static BOOL init_threadpool(void)
...
@@ -47,10 +51,14 @@ static BOOL init_threadpool(void)
NTDLL_GET_PROC
(
TpAllocCleanupGroup
);
NTDLL_GET_PROC
(
TpAllocCleanupGroup
);
NTDLL_GET_PROC
(
TpAllocPool
);
NTDLL_GET_PROC
(
TpAllocPool
);
NTDLL_GET_PROC
(
TpAllocWork
);
NTDLL_GET_PROC
(
TpPostWork
);
NTDLL_GET_PROC
(
TpReleaseCleanupGroup
);
NTDLL_GET_PROC
(
TpReleaseCleanupGroup
);
NTDLL_GET_PROC
(
TpReleaseCleanupGroupMembers
);
NTDLL_GET_PROC
(
TpReleaseCleanupGroupMembers
);
NTDLL_GET_PROC
(
TpReleasePool
);
NTDLL_GET_PROC
(
TpReleasePool
);
NTDLL_GET_PROC
(
TpReleaseWork
);
NTDLL_GET_PROC
(
TpSimpleTryPost
);
NTDLL_GET_PROC
(
TpSimpleTryPost
);
NTDLL_GET_PROC
(
TpWaitForWork
);
if
(
!
pTpAllocPool
)
if
(
!
pTpAllocPool
)
{
{
...
@@ -167,10 +175,61 @@ static void test_tp_simple(void)
...
@@ -167,10 +175,61 @@ static void test_tp_simple(void)
CloseHandle
(
semaphore
);
CloseHandle
(
semaphore
);
}
}
static
void
CALLBACK
work_cb
(
TP_CALLBACK_INSTANCE
*
instance
,
void
*
userdata
,
TP_WORK
*
work
)
{
trace
(
"Running work callback
\n
"
);
Sleep
(
10
);
InterlockedIncrement
((
LONG
*
)
userdata
);
}
static
void
test_tp_work
(
void
)
{
TP_CALLBACK_ENVIRON
environment
;
TP_WORK
*
work
;
TP_POOL
*
pool
;
NTSTATUS
status
;
LONG
userdata
;
int
i
;
/* allocate new threadpool */
pool
=
NULL
;
status
=
pTpAllocPool
(
&
pool
,
NULL
);
ok
(
!
status
,
"TpAllocPool failed with status %x
\n
"
,
status
);
ok
(
pool
!=
NULL
,
"expected pool != NULL
\n
"
);
/* allocate new work item */
work
=
NULL
;
memset
(
&
environment
,
0
,
sizeof
(
environment
));
environment
.
Version
=
1
;
environment
.
Pool
=
pool
;
status
=
pTpAllocWork
(
&
work
,
work_cb
,
&
userdata
,
&
environment
);
ok
(
!
status
,
"TpAllocWork failed with status %x
\n
"
,
status
);
ok
(
work
!=
NULL
,
"expected work != NULL
\n
"
);
/* post 10 identical work items at once */
userdata
=
0
;
for
(
i
=
0
;
i
<
10
;
i
++
)
pTpPostWork
(
work
);
pTpWaitForWork
(
work
,
FALSE
);
ok
(
userdata
==
10
,
"expected userdata = 10, got %u
\n
"
,
userdata
);
/* add more tasks and cancel them immediately */
userdata
=
0
;
for
(
i
=
0
;
i
<
10
;
i
++
)
pTpPostWork
(
work
);
pTpWaitForWork
(
work
,
TRUE
);
ok
(
userdata
<
10
,
"expected userdata < 10, got %u
\n
"
,
userdata
);
/* cleanup */
pTpReleaseWork
(
work
);
pTpReleasePool
(
pool
);
}
START_TEST
(
threadpool
)
START_TEST
(
threadpool
)
{
{
if
(
!
init_threadpool
())
if
(
!
init_threadpool
())
return
;
return
;
test_tp_simple
();
test_tp_simple
();
test_tp_work
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment