ReactOS  0.4.15-dev-1207-g698a8e6
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 
11 static DWORD s_record_count = 0;
12 static DWORD s_record[MAX_RECORD + 1] = { 0 };
14 
15 static 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 
25 static void AddValueToRecord(DWORD dwValue)
26 {
27  s_record[s_record_count] = dwValue;
30 }
31 
32 static 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",
47  (int)s_record_count, (int)s_expected_count);
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 
105  hThread = CreateThread(NULL, 0, fn, NULL, 0, &dwThreadId);
106  ok(hThread != NULL, "hThread was NULL\n");
107 
108  Sleep(100);
109 
110  AddValueToRecord(7);
112  AddValueToRecord(8);
113 
114  Sleep(100);
115 
116  AddValueToRecord(9);
118  AddValueToRecord(10);
119 
120  Sleep(100);
121 
122  AddValueToRecord(11);
124  AddValueToRecord(12);
125 
126  AddValueToRecord(13);
128  AddValueToRecord(14);
129 
130  AddValueToRecord(15);
132  hThread = NULL;
133  AddValueToRecord(16);
134 
135  CheckRecord();
136 }
137 
138 static void TestForSleepEx(void)
139 {
141 }
142 
144 {
146 }
147 
149 {
150  TestForSleepEx();
152 }
static void JustDoIt(LPTHREAD_START_ROUTINE fn)
Definition: QueueUserAPC.c:96
#define abs(i)
Definition: fconv.c:206
DWORD WINAPI WaitForSingleObjectEx(IN HANDLE hHandle, IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:94
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:707
#define CloseHandle
Definition: compat.h:598
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
static void AddValueToRecord(DWORD dwValue)
Definition: QueueUserAPC.c:25
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
#define TRUE
Definition: types.h:120
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ZeroMemory
Definition: winbase.h:1648
static void TestForWaitForSingleObjectEx(void)
Definition: QueueUserAPC.c:143
static VOID CheckRecord(void)
Definition: QueueUserAPC.c:32
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define ok_long(expression, result)
Definition: atltest.h:133
int32_t INT
Definition: typedefs.h:58
static const DWORD s_expected[]
Definition: QueueUserAPC.c:15
uint32_t ULONG_PTR
Definition: typedefs.h:65
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
DWORD WINAPI QueueUserAPC(IN PAPCFUNC pfnAPC, IN HANDLE hThread, IN ULONG_PTR dwData)
Definition: thread.c:947
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
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
HANDLE WINAPI GetCurrentThread(VOID)
Definition: proc.c:1148
unsigned int BOOL
Definition: ntddk_ex.h:94
static DWORD WINAPI ThreadFunc1(LPVOID arg)
Definition: QueueUserAPC.c:51
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:136
smooth NULL
Definition: ftsmooth.c:416
#define ok_int(expression, result)
Definition: atltest.h:134
static VOID NTAPI DoUserAPC2(ULONG_PTR Parameter)
Definition: QueueUserAPC.c:83
static void TestForSleepEx(void)
Definition: QueueUserAPC.c:138
#define WAIT_IO_COMPLETION
Definition: winbase.h:392
static DWORD s_record_count
Definition: QueueUserAPC.c:11
DWORD WINAPI SleepEx(IN DWORD dwMilliseconds, IN BOOL bAlertable)
Definition: synch.c:802
#define WAIT_OBJECT_0
Definition: winbase.h:387
#define _countof(array)
Definition: sndvol32.h:68
#define WINAPI
Definition: msvc.h:6
static const SIZE_T s_expected_count
Definition: QueueUserAPC.c:23
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD dwThreadId
Definition: fdebug.c:31
START_TEST(QueueUserAPC)
Definition: QueueUserAPC.c:148
#define MAX_RECORD
Definition: QueueUserAPC.c:9
ULONG_PTR SIZE_T
Definition: typedefs.h:80
static VOID NTAPI DoUserAPC1(ULONG_PTR Parameter)
Definition: QueueUserAPC.c:77
static BOOL s_terminate_all
Definition: QueueUserAPC.c:13
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
static VOID NTAPI DoUserAPC3(ULONG_PTR Parameter)
Definition: QueueUserAPC.c:89
static DWORD WINAPI ThreadFunc2(LPVOID arg)
Definition: QueueUserAPC.c:64
HANDLE hThread
Definition: wizard.c:27
static DWORD s_record[MAX_RECORD+1]
Definition: QueueUserAPC.c:12
#define INFINITE
Definition: serial.h:102