Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
634bbed3
Commit
634bbed3
authored
Jul 05, 2015
by
Sebastian Lackner
Committed by
Alexandre Julliard
Jul 06, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll/tests: Add threadpool wait tests with more than 63 objects.
parent
553ae488
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
0 deletions
+120
-0
threadpool.c
dlls/ntdll/tests/threadpool.c
+120
-0
No files found.
dlls/ntdll/tests/threadpool.c
View file @
634bbed3
...
...
@@ -1171,6 +1171,125 @@ static void test_tp_wait(void)
CloseHandle
(
semaphores
[
1
]);
}
static
struct
{
HANDLE
semaphore
;
DWORD
result
;
}
multi_wait_info
;
static
void
CALLBACK
multi_wait_cb
(
TP_CALLBACK_INSTANCE
*
instance
,
void
*
userdata
,
TP_WAIT
*
wait
,
TP_WAIT_RESULT
result
)
{
DWORD
index
=
(
DWORD
)(
DWORD_PTR
)
userdata
;
if
(
result
==
WAIT_OBJECT_0
)
multi_wait_info
.
result
=
index
;
else
if
(
result
==
WAIT_TIMEOUT
)
multi_wait_info
.
result
=
0x10000
|
index
;
else
ok
(
0
,
"unexpected result %u
\n
"
,
result
);
ReleaseSemaphore
(
multi_wait_info
.
semaphore
,
1
,
NULL
);
}
static
void
test_tp_multi_wait
(
void
)
{
TP_CALLBACK_ENVIRON
environment
;
HANDLE
semaphores
[
512
];
TP_WAIT
*
waits
[
512
];
LARGE_INTEGER
when
;
HANDLE
semaphore
;
NTSTATUS
status
;
TP_POOL
*
pool
;
DWORD
result
;
int
i
;
semaphore
=
CreateSemaphoreW
(
NULL
,
0
,
512
,
NULL
);
ok
(
semaphore
!=
NULL
,
"failed to create semaphore
\n
"
);
multi_wait_info
.
semaphore
=
semaphore
;
/* 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
"
);
memset
(
&
environment
,
0
,
sizeof
(
environment
));
environment
.
Version
=
1
;
environment
.
Pool
=
pool
;
/* create semaphores and corresponding wait objects */
for
(
i
=
0
;
i
<
sizeof
(
semaphores
)
/
sizeof
(
semaphores
[
0
]);
i
++
)
{
semaphores
[
i
]
=
CreateSemaphoreW
(
NULL
,
0
,
1
,
NULL
);
ok
(
semaphores
[
i
]
!=
NULL
,
"failed to create semaphore %i
\n
"
,
i
);
waits
[
i
]
=
NULL
;
status
=
pTpAllocWait
(
&
waits
[
i
],
multi_wait_cb
,
(
void
*
)(
DWORD_PTR
)
i
,
&
environment
);
ok
(
!
status
,
"TpAllocWait failed with status %x
\n
"
,
status
);
ok
(
waits
[
i
]
!=
NULL
,
"expected waits[%d] != NULL
\n
"
,
i
);
pTpSetWait
(
waits
[
i
],
semaphores
[
i
],
NULL
);
}
/* release all semaphores and wait for callback */
for
(
i
=
0
;
i
<
sizeof
(
semaphores
)
/
sizeof
(
semaphores
[
0
]);
i
++
)
{
multi_wait_info
.
result
=
0
;
ReleaseSemaphore
(
semaphores
[
i
],
1
,
NULL
);
result
=
WaitForSingleObject
(
semaphore
,
100
);
ok
(
result
==
WAIT_OBJECT_0
,
"WaitForSingleObject returned %u
\n
"
,
result
);
ok
(
multi_wait_info
.
result
==
i
,
"expected result %d, got %u
\n
"
,
i
,
multi_wait_info
.
result
);
pTpSetWait
(
waits
[
i
],
semaphores
[
i
],
NULL
);
}
/* repeat the same test in reverse order */
for
(
i
=
sizeof
(
semaphores
)
/
sizeof
(
semaphores
[
0
])
-
1
;
i
>=
0
;
i
--
)
{
multi_wait_info
.
result
=
0
;
ReleaseSemaphore
(
semaphores
[
i
],
1
,
NULL
);
result
=
WaitForSingleObject
(
semaphore
,
100
);
ok
(
result
==
WAIT_OBJECT_0
,
"WaitForSingleObject returned %u
\n
"
,
result
);
ok
(
multi_wait_info
.
result
==
i
,
"expected result %d, got %u
\n
"
,
i
,
multi_wait_info
.
result
);
pTpSetWait
(
waits
[
i
],
semaphores
[
i
],
NULL
);
}
/* test timeout of wait objects */
multi_wait_info
.
result
=
0
;
for
(
i
=
0
;
i
<
sizeof
(
semaphores
)
/
sizeof
(
semaphores
[
0
]);
i
++
)
{
when
.
QuadPart
=
(
ULONGLONG
)
50
*
-
10000
;
pTpSetWait
(
waits
[
i
],
semaphores
[
i
],
&
when
);
}
for
(
i
=
0
;
i
<
sizeof
(
semaphores
)
/
sizeof
(
semaphores
[
0
]);
i
++
)
{
result
=
WaitForSingleObject
(
semaphore
,
150
);
ok
(
result
==
WAIT_OBJECT_0
,
"WaitForSingleObject returned %u
\n
"
,
result
);
}
ok
(
multi_wait_info
.
result
>>
16
,
"expected multi_wait_info.result >> 16 != 0
\n
"
);
/* destroy the wait objects and semaphores while waiting */
for
(
i
=
0
;
i
<
sizeof
(
semaphores
)
/
sizeof
(
semaphores
[
0
]);
i
++
)
{
pTpSetWait
(
waits
[
i
],
semaphores
[
i
],
NULL
);
}
Sleep
(
50
);
for
(
i
=
0
;
i
<
sizeof
(
semaphores
)
/
sizeof
(
semaphores
[
0
]);
i
++
)
{
pTpReleaseWait
(
waits
[
i
]);
NtClose
(
semaphores
[
i
]);
}
pTpReleasePool
(
pool
);
CloseHandle
(
semaphore
);
}
START_TEST
(
threadpool
)
{
if
(
!
init_threadpool
())
...
...
@@ -1185,4 +1304,5 @@ START_TEST(threadpool)
test_tp_timer
();
test_tp_window_length
();
test_tp_wait
();
test_tp_multi_wait
();
}
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