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
f31c3e38
Commit
f31c3e38
authored
Apr 03, 2002
by
Geoffrey Hausheer
Committed by
Alexandre Julliard
Apr 03, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up a bit, removed todos for OpenThread, avoid TerminateThread
race.
parent
01c8ec3a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
29 deletions
+21
-29
thread.c
dlls/kernel/tests/thread.c
+21
-29
No files found.
dlls/kernel/tests/thread.c
View file @
f31c3e38
...
@@ -18,18 +18,15 @@
...
@@ -18,18 +18,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
*/
#include
<stdio.h>
#include
"wine/test.h"
#include <winbase.h>
#include <winbase.h>
#include <winnt.h>
#include <winnt.h>
#include <winerror.h>
#include <winerror.h>
#include "wine/test.h"
/* Specify the number of simultaneous threads to test */
/* Specify the number of simultaneous threads to test */
#define NUM_THREADS 4
#define NUM_THREADS 4
/* Specify whether to test the extended priorities for Win2k/XP */
/* Specify whether to test the extended priorities for Win2k/XP */
#define USE_EXTENDED_PRIORITIES 0
#define USE_EXTENDED_PRIORITIES 0
/* Specify whether the TerminateThread tests should be skipped */
#define SKIP_TERMINATE 0
/* Specify whether to test the stack allocation in CreateThread */
/* Specify whether to test the stack allocation in CreateThread */
#define CHECK_STACK 0
#define CHECK_STACK 0
...
@@ -118,8 +115,11 @@ VOID WINAPI threadFunc3()
...
@@ -118,8 +115,11 @@ VOID WINAPI threadFunc3()
ExitThread
(
99
);
ExitThread
(
99
);
}
}
VOID
WINAPI
threadFunc4
()
VOID
WINAPI
threadFunc4
(
HANDLE
event
)
{
{
if
(
event
!=
(
HANDLE
)
NULL
)
{
SetEvent
(
event
);
}
Sleep
(
99000
);
Sleep
(
99000
);
ExitThread
(
0
);
ExitThread
(
0
);
}
}
...
@@ -265,7 +265,6 @@ VOID test_SuspendThread(DWORD version)
...
@@ -265,7 +265,6 @@ VOID test_SuspendThread(DWORD version)
if
(
WIN2K_PLUS
(
version
))
{
if
(
WIN2K_PLUS
(
version
))
{
access_thread
=
OpenThreadPtr
(
THREAD_ALL_ACCESS
&
(
~
THREAD_SUSPEND_RESUME
),
access_thread
=
OpenThreadPtr
(
THREAD_ALL_ACCESS
&
(
~
THREAD_SUSPEND_RESUME
),
0
,
threadId
);
0
,
threadId
);
todo_wine
{
ok
(
access_thread
!=
(
HANDLE
)
NULL
,
"OpenThread returned an invalid handle"
);
ok
(
access_thread
!=
(
HANDLE
)
NULL
,
"OpenThread returned an invalid handle"
);
if
(
access_thread
!=
(
HANDLE
)
NULL
)
{
if
(
access_thread
!=
(
HANDLE
)
NULL
)
{
ok
(
SuspendThread
(
access_thread
)
==-
1
,
ok
(
SuspendThread
(
access_thread
)
==-
1
,
...
@@ -275,7 +274,6 @@ VOID test_SuspendThread(DWORD version)
...
@@ -275,7 +274,6 @@ VOID test_SuspendThread(DWORD version)
ok
(
CloseHandle
(
access_thread
)
!=
0
,
"CloseHandle Failed"
);
ok
(
CloseHandle
(
access_thread
)
!=
0
,
"CloseHandle Failed"
);
}
}
}
}
}
/* Double check that the thread really is suspended */
/* Double check that the thread really is suspended */
ok
((
error
=
GetExitCodeThread
(
thread
,
&
exitCode
))
!=
0
&&
exitCode
==
STILL_ACTIVE
,
ok
((
error
=
GetExitCodeThread
(
thread
,
&
exitCode
))
!=
0
&&
exitCode
==
STILL_ACTIVE
,
"Thread did not really suspend"
);
"Thread did not really suspend"
);
...
@@ -290,25 +288,28 @@ VOID test_SuspendThread(DWORD version)
...
@@ -290,25 +288,28 @@ VOID test_SuspendThread(DWORD version)
}
}
/* Check that TerminateThread works properly
/* Check that TerminateThread works properly
NOTE: in my wine version (As of March 30, 2002), this code leaves a wine
process after the test completes. You can use SKIP_TERMINATE to disable
the testing, and not leave the wine process around.
*/
*/
VOID
test_TerminateThread
(
DWORD
version
)
VOID
test_TerminateThread
(
DWORD
version
)
{
{
HANDLE
thread
,
access_thread
;
HANDLE
thread
,
access_thread
,
event
;
DWORD
threadId
,
exitCode
;
DWORD
threadId
,
exitCode
;
int
i
,
error
;
int
i
,
error
;
char
msg
[
80
];
i
=
0
;
error
=
0
;
i
=
0
;
error
=
0
;
thread
=
CreateThread
(
NULL
,
0
,(
LPTHREAD_START_ROUTINE
)
threadFunc4
,
NULL
,
event
=
CreateEventA
(
NULL
,
TRUE
,
FALSE
,
NULL
);
0
,
&
threadId
);
thread
=
CreateThread
(
NULL
,
0
,(
LPTHREAD_START_ROUTINE
)
threadFunc4
,
(
LPVOID
)
event
,
0
,
&
threadId
);
ok
(
thread
!=
(
HANDLE
)
NULL
,
"Create Thread failed."
);
ok
(
thread
!=
(
HANDLE
)
NULL
,
"Create Thread failed."
);
/* Terminate thread has a race condition in Wine. If the thread is terminated
before it starts, it leaves a process behind. Therefore, we wait for the
thread to signal that it has started. There is no easy way to force the
race to occur, so we don't try to find it.
*/
ok
(
WaitForSingleObject
(
event
,
5000
)
==
WAIT_OBJECT_0
,
"TerminateThread didn't work"
);
/* check that access restrictions are obeyed */
/* check that access restrictions are obeyed */
if
(
WIN2K_PLUS
(
version
))
{
if
(
WIN2K_PLUS
(
version
))
{
access_thread
=
OpenThreadPtr
(
THREAD_ALL_ACCESS
&
(
~
THREAD_TERMINATE
),
access_thread
=
OpenThreadPtr
(
THREAD_ALL_ACCESS
&
(
~
THREAD_TERMINATE
),
0
,
threadId
);
0
,
threadId
);
todo_wine
{
ok
(
access_thread
!=
(
HANDLE
)
NULL
,
"OpenThread returned an invalid handle"
);
ok
(
access_thread
!=
(
HANDLE
)
NULL
,
"OpenThread returned an invalid handle"
);
if
(
access_thread
!=
(
HANDLE
)
NULL
)
{
if
(
access_thread
!=
(
HANDLE
)
NULL
)
{
ok
(
TerminateThread
(
access_thread
,
99
)
==
0
,
ok
(
TerminateThread
(
access_thread
,
99
)
==
0
,
...
@@ -316,7 +317,6 @@ VOID test_TerminateThread(DWORD version)
...
@@ -316,7 +317,6 @@ VOID test_TerminateThread(DWORD version)
ok
(
CloseHandle
(
access_thread
)
!=
0
,
"CloseHandle Failed"
);
ok
(
CloseHandle
(
access_thread
)
!=
0
,
"CloseHandle Failed"
);
}
}
}
}
}
/* terminate a job and make sure it terminates */
/* terminate a job and make sure it terminates */
ok
(
TerminateThread
(
thread
,
99
)
!=
0
,
"TerminateThread failed"
);
ok
(
TerminateThread
(
thread
,
99
)
!=
0
,
"TerminateThread failed"
);
ok
(
WaitForSingleObject
(
thread
,
5000
)
==
WAIT_OBJECT_0
,
ok
(
WaitForSingleObject
(
thread
,
5000
)
==
WAIT_OBJECT_0
,
...
@@ -328,8 +328,7 @@ VOID test_TerminateThread(DWORD version)
...
@@ -328,8 +328,7 @@ VOID test_TerminateThread(DWORD version)
TerminateThread, even though MSDN says it should. So currently
TerminateThread, even though MSDN says it should. So currently
there is no check being done for this.
there is no check being done for this.
*/
*/
sprintf
(
msg
,
"TerminateThread returned: 0x%lx instead of 0x%x
\n
"
,
exitCode
,
99
);
trace
(
"TerminateThread returned: 0x%lx instead of 0x%x
\n
"
,
exitCode
,
99
);
trace
(
msg
);
}
else
{
}
else
{
ok
(
exitCode
==
99
,
"TerminateThread returned invalid exit code"
);
ok
(
exitCode
==
99
,
"TerminateThread returned invalid exit code"
);
}
}
...
@@ -372,7 +371,6 @@ VOID test_thread_priority(DWORD version)
...
@@ -372,7 +371,6 @@ VOID test_thread_priority(DWORD version)
DWORD
curthreadId
,
exitCode
;
DWORD
curthreadId
,
exitCode
;
int
min_priority
=-
2
,
max_priority
=
2
;
int
min_priority
=-
2
,
max_priority
=
2
;
int
i
,
error
;
int
i
,
error
;
char
msg1
[
80
],
msg2
[
80
];
curthread
=
GetCurrentThread
();
curthread
=
GetCurrentThread
();
curthreadId
=
GetCurrentThreadId
();
curthreadId
=
GetCurrentThreadId
();
...
@@ -390,7 +388,6 @@ VOID test_thread_priority(DWORD version)
...
@@ -390,7 +388,6 @@ VOID test_thread_priority(DWORD version)
access_thread
=
OpenThreadPtr
(
THREAD_ALL_ACCESS
&
access_thread
=
OpenThreadPtr
(
THREAD_ALL_ACCESS
&
(
~
THREAD_QUERY_INFORMATION
)
&
(
~
THREAD_SET_INFORMATION
),
(
~
THREAD_QUERY_INFORMATION
)
&
(
~
THREAD_SET_INFORMATION
),
0
,
curthreadId
);
0
,
curthreadId
);
todo_wine
{
ok
(
access_thread
!=
(
HANDLE
)
NULL
,
"OpenThread returned an invalid handle"
);
ok
(
access_thread
!=
(
HANDLE
)
NULL
,
"OpenThread returned an invalid handle"
);
if
(
access_thread
!=
(
HANDLE
)
NULL
)
{
if
(
access_thread
!=
(
HANDLE
)
NULL
)
{
ok
(
SetThreadPriority
(
access_thread
,
1
)
==
0
,
ok
(
SetThreadPriority
(
access_thread
,
1
)
==
0
,
...
@@ -405,16 +402,15 @@ VOID test_thread_priority(DWORD version)
...
@@ -405,16 +402,15 @@ VOID test_thread_priority(DWORD version)
"GetExitCodeThread did not obey access restrictions"
);
"GetExitCodeThread did not obey access restrictions"
);
ok
(
CloseHandle
(
access_thread
),
"Error Closing thread handle"
);
ok
(
CloseHandle
(
access_thread
),
"Error Closing thread handle"
);
}
}
}
#if USE_EXTENDED_PRIORITIES
#if USE_EXTENDED_PRIORITIES
min_priority
=-
7
;
max_priority
=
6
;
min_priority
=-
7
;
max_priority
=
6
;
#endif
#endif
}
}
for
(
i
=
min_priority
;
i
<=
max_priority
;
i
++
)
{
for
(
i
=
min_priority
;
i
<=
max_priority
;
i
++
)
{
sprintf
(
msg1
,
"SetThreadPriority Failed for priority: %d"
,
i
);
ok
(
SetThreadPriority
(
curthread
,
i
)
!=
0
,
sprintf
(
msg2
,
"G
etThreadPriority Failed for priority: %d"
,
i
);
"S
etThreadPriority Failed for priority: %d"
,
i
);
ok
(
SetThreadPriority
(
curthread
,
i
)
!=
0
,
msg1
);
ok
(
GetThreadPriority
(
curthread
)
==
i
,
ok
(
GetThreadPriority
(
curthread
)
==
i
,
msg2
);
"GetThreadPriority Failed for priority: %d"
,
i
);
}
}
ok
(
SetThreadPriority
(
curthread
,
THREAD_PRIORITY_TIME_CRITICAL
)
!=
0
,
ok
(
SetThreadPriority
(
curthread
,
THREAD_PRIORITY_TIME_CRITICAL
)
!=
0
,
"SetThreadPriority Failed"
);
"SetThreadPriority Failed"
);
...
@@ -458,11 +454,9 @@ VOID test_GetThreadTimes(DWORD version)
...
@@ -458,11 +454,9 @@ VOID test_GetThreadTimes(DWORD version)
if
(
WIN2K_PLUS
(
version
))
{
if
(
WIN2K_PLUS
(
version
))
{
access_thread
=
OpenThreadPtr
(
THREAD_ALL_ACCESS
&
access_thread
=
OpenThreadPtr
(
THREAD_ALL_ACCESS
&
(
~
THREAD_QUERY_INFORMATION
),
0
,
threadId
);
(
~
THREAD_QUERY_INFORMATION
),
0
,
threadId
);
todo_wine
{
ok
(
access_thread
!=
(
HANDLE
)
NULL
,
ok
(
access_thread
!=
(
HANDLE
)
NULL
,
"OpenThread returned an invalid handle"
);
"OpenThread returned an invalid handle"
);
}
}
}
ok
(
ResumeThread
(
thread
)
==
1
,
"Resume thread returned an invalid value"
);
ok
(
ResumeThread
(
thread
)
==
1
,
"Resume thread returned an invalid value"
);
ok
(
WaitForSingleObject
(
thread
,
5000
)
==
WAIT_OBJECT_0
,
ok
(
WaitForSingleObject
(
thread
,
5000
)
==
WAIT_OBJECT_0
,
"ResumeThread didn't work"
);
"ResumeThread didn't work"
);
...
@@ -554,9 +548,7 @@ START_TEST(thread)
...
@@ -554,9 +548,7 @@ START_TEST(thread)
test_CreateThread_basic
(
version
);
test_CreateThread_basic
(
version
);
test_CreateThread_suspended
(
version
);
test_CreateThread_suspended
(
version
);
test_SuspendThread
(
version
);
test_SuspendThread
(
version
);
#if ! SKIP_TERMINATE
test_TerminateThread
(
version
);
test_TerminateThread
(
version
);
#endif
test_CreateThread_stack
(
version
);
test_CreateThread_stack
(
version
);
test_thread_priority
(
version
);
test_thread_priority
(
version
);
test_GetThreadTimes
(
version
);
test_GetThreadTimes
(
version
);
...
...
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