ReactOS 0.4.16-dev-91-g764881a
QueueUserAPC.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4 * PURPOSE: Tests for QueueUserAPC, SleepEx, WaitForSingleObjectEx etc.
5 * COPYRIGHT: Copyright 2020 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7#include "precomp.h"
8
9#define MAX_RECORD 30
10
12static DWORD s_record[MAX_RECORD + 1] = { 0 };
14
15static const DWORD s_expected[] =
16{
17 0, 1, 7, 8, 4,
18 2, 1, 9, 10, 5,
19 2, 1, 11, 12, 13,
20 6, 2, 3, 14, 15,
21 16
22};
24
25static void AddValueToRecord(DWORD dwValue)
26{
28 if (next < MAX_RECORD)
29 s_record[next] = dwValue;
30}
31
32static VOID CheckRecord(void)
33{
35
36 for (i = 0; i < count; ++i)
37 {
38 ok(s_record[i] == s_expected[i], "s_record[%u]: got %lu vs expected %lu\n",
39 (INT)i, s_record[i], s_expected[i]);
40 }
41
43 for (i = 0; i < count; ++i)
44 {
46 "s_record_count: got %u vs expected %u\n",
48 }
49}
50
52{
54 while (!s_terminate_all)
55 {
59 }
61 return 0;
62}
63
65{
67 while (!s_terminate_all)
68 {
72 }
74 return 0;
75}
76
78{
79 ok_int((int)Parameter, 1);
81}
82
84{
85 ok_int((int)Parameter, 2);
87}
88
90{
91 ok_int((int)Parameter, 3);
94}
95
97{
100
102 s_record_count = 0;
103 ZeroMemory(s_record, sizeof(s_record));
104
106 ok(hThread != NULL, "hThread was NULL\n");
107
108 Sleep(100);
109
113
114 Sleep(100);
115
119
120 Sleep(100);
121
125
129
132 hThread = NULL;
134
135 CheckRecord();
136}
137
138static void TestForSleepEx(void)
139{
141}
142
144{
146}
147
149{
150 return 0;
151}
152
153static void TestMultipleUserAPCs(void)
154{
157
158 s_record_count = 0;
159
161 ok(hThread != NULL, "hThread was NULL\n");
162
166
168
170
173
175 ok_long(s_record[0], 4);
176 ok_long(s_record[1], 5);
177 ok_long(s_record[2], 6);
178}
179
181{
185}
static void JustDoIt(void)
static void TestForWaitForSingleObjectEx(void)
Definition: QueueUserAPC.c:143
static DWORD WINAPI ThreadFunc3(LPVOID arg)
Definition: QueueUserAPC.c:148
#define MAX_RECORD
Definition: QueueUserAPC.c:9
static VOID NTAPI DoUserAPC2(ULONG_PTR Parameter)
Definition: QueueUserAPC.c:83
static const DWORD s_expected[]
Definition: QueueUserAPC.c:15
static void TestForSleepEx(void)
Definition: QueueUserAPC.c:138
static VOID CheckRecord(void)
Definition: QueueUserAPC.c:32
static BOOL s_terminate_all
Definition: QueueUserAPC.c:13
static VOID NTAPI DoUserAPC3(ULONG_PTR Parameter)
Definition: QueueUserAPC.c:89
static DWORD s_record[MAX_RECORD+1]
Definition: QueueUserAPC.c:12
static const SIZE_T s_expected_count
Definition: QueueUserAPC.c:23
static DWORD WINAPI ThreadFunc1(LPVOID arg)
Definition: QueueUserAPC.c:51
static void AddValueToRecord(DWORD dwValue)
Definition: QueueUserAPC.c:25
static void TestMultipleUserAPCs(void)
Definition: QueueUserAPC.c:153
static LONG s_record_count
Definition: QueueUserAPC.c:11
static VOID NTAPI DoUserAPC1(ULONG_PTR Parameter)
Definition: QueueUserAPC.c:77
static DWORD WINAPI ThreadFunc2(LPVOID arg)
Definition: QueueUserAPC.c:64
#define InterlockedIncrement
Definition: armddk.h:53
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
DWORD WINAPI QueueUserAPC(IN PAPCFUNC pfnAPC, IN HANDLE hThread, IN ULONG_PTR dwData)
Definition: thread.c:959
DWORD WINAPI ResumeThread(IN HANDLE hThread)
Definition: thread.c:567
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define INFINITE
Definition: serial.h:102
#define abs(i)
Definition: fconv.c:206
DWORD dwThreadId
Definition: fdebug.c:31
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define min(a, b)
Definition: monoChain.cc:55
HANDLE hThread
Definition: wizard.c:28
long LONG
Definition: pedump.c:60
static unsigned __int64 next
Definition: rand_nt.c:6
#define _countof(array)
Definition: sndvol32.h:70
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:802
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
#define ZeroMemory
Definition: winbase.h:1712
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
#define WAIT_IO_COMPLETION
Definition: winbase.h:411
#define CREATE_SUSPENDED
Definition: winbase.h:178
#define WAIT_OBJECT_0
Definition: winbase.h:406
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:729
#define WINAPI
Definition: msvc.h:6
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336