73{
75 ULONG i, ulInitCount, ulSeed;
78
84
85
88 {
89 skip(
"Module kernel32 not found\n");
90 return;
91 }
96
97
98
99
100
104 {
106 }
107
108
110 if (pfnInitOnceInitialize)
111 {
112 pfnInitOnceInitialize(&InitOnce);
113 }
114 else
115 {
116 skip(
"InitOnceInitialize not found\n");
118 }
119
120 if (!pfnInitOnceExecuteOnce)
121 {
122 skip(
"InitOnceExecuteOnce not found\n");
123 goto _test_sync;
124 }
125
126
127
128
129
130
131
132 ulInitCount = 0;
134 bRet = pfnInitOnceExecuteOnce(&InitOnce, InitOnceProc, &ulInitCount, (
LPVOID*)&ulContextData);
135 ok(bRet,
"InitOnceExecuteOnce failed with %lu\n",
GetLastError());
136 if (bRet)
137 {
138
139 bRet = pfnInitOnceExecuteOnce(&InitOnce,
140 InitOnceProc,
141 &ulInitCount,
143 ok(bRet,
"InitOnceExecuteOnce failed with %lu\n",
GetLastError());
144 ok(ulInitCount == 1,
"ulInitCount is not 1\n");
145 ok(ulContextData ==
g_ulRandom,
"Output ulContextData is incorrect\n");
146 }
147
148_test_sync:
149 if (!pfnInitOnceBeginInitialize || !pfnInitOnceComplete)
150 {
151 skip(
"InitOnceBeginInitialize or InitOnceComplete not found\n");
152 return;
153 }
154
155
157 ulContextData = 0xdeadbeef;
158
159
161 bRet = pfnInitOnceBeginInitialize(&InitOnce, 0, &fPending, (
LPVOID*)&ulContextData);
162 ok(bRet,
"InitOnceBeginInitialize failed with %lu\n",
GetLastError());
163 if (!bRet)
164 {
165 goto _test_async;
166 }
167 ok(fPending,
"fPending is not TRUE after the first success InitOnceBeginInitialize\n");
168 if (!fPending)
169 {
170 goto _test_async;
171 }
172
173
174 fPending = 0xdeadbeef;
175 bRet = pfnInitOnceBeginInitialize(&InitOnce,
177 &fPending,
179 ok(bRet ==
FALSE,
"InitOnceBeginInitialize should fail\n");
180 ok(fPending == 0xdeadbeef,
"fPending should be unmodified\n");
181 ok(ulContextData == 0xdeadbeef,
"ulContextData should be unmodified\n");
182
183
185 bRet = pfnInitOnceComplete(&InitOnce, 0, (
LPVOID)ulTempContext);
187 if (!bRet)
188 {
189 goto _test_async;
190 }
191
192
193
194
195
196 bRet = pfnInitOnceBeginInitialize(&InitOnce,
198 &fPending,
201 "InitOnceBeginInitialize returns incorrect result for a completed initialization\n");
202
203_test_async:
205
206
208 bRet = pfnInitOnceBeginInitialize(&InitOnce,
210 &fPending,
212 ok(bRet,
"InitOnceBeginInitialize failed with %lu\n",
GetLastError());
213 if (!bRet)
214 {
215 return;
216 }
217 ok(fPending,
"fPending is not TRUE after a success InitOnceBeginInitialize\n");
218 if (!fPending)
219 {
220 return;
221 }
222
223
224
225
226
227
228 bRet = pfnInitOnceBeginInitialize(&InitOnce, 0, &fPending, (
LPVOID*)&ulContextData);
229 ok(!bRet,
"InitOnceBeginInitialize should not success\n");
230 if (!bRet)
231 {
234 "Last error is %lu, but %u is expected\n",
235 dwError,
237 }
238
239
240
241
242
243 bRet = pfnInitOnceBeginInitialize(&InitOnce,
245 &fPending,
247 ok(bRet,
"InitOnceBeginInitialize failed with %lu\n",
GetLastError());
248 if (!bRet)
249 {
250 return;
251 }
252 ok(fPending,
"fPending is not TRUE after a success InitOnceBeginInitialize\n");
253 if (!fPending)
254 {
255 return;
256 }
257
258
262 if (!bRet)
263 {
264 return;
265 }
266
267
269 ok(!bRet,
"InitOnceComplete should not success\n");
270 if (!bRet)
271 {
274 "Last error is %lu, but %u is expected\n",
275 dwError,
277 }
278
279
280
281
282
283 bRet = pfnInitOnceBeginInitialize(&InitOnce,
285 &fPending,
288 "InitOnceBeginInitialize returns incorrect result for a completed initialization\n");
289
290 return;
291}
#define ERROR_INVALID_PARAMETER
#define GetProcAddress(x, y)
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
DWORD WINAPI GetTickCount(VOID)
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
BOOL WINAPI FN_InitOnceBeginInitialize(_Inout_ LPINIT_ONCE lpInitOnce, _In_ DWORD dwFlags, _Out_ PBOOL fPending, _Outptr_opt_result_maybenull_ LPVOID *lpContext)
BOOL WINAPI FN_InitOnceComplete(_Inout_ LPINIT_ONCE lpInitOnce, _In_ DWORD dwFlags, _In_opt_ LPVOID lpContext)
VOID WINAPI FN_InitOnceInitialize(_Out_ PINIT_ONCE InitOnce)
BOOL WINAPI FN_InitOnceExecuteOnce(_Inout_ PINIT_ONCE InitOnce, _In_ __callback PINIT_ONCE_FN InitFn, _Inout_opt_ PVOID Parameter, _Outptr_opt_result_maybenull_ LPVOID *Context)
NTSYSAPI ULONG NTAPI RtlRandom(_Inout_ PULONG Seed)
DWORD WINAPI GetLastError(void)
#define INIT_ONCE_CHECK_ONLY
#define INIT_ONCE_CTX_RESERVED_BITS
#define INIT_ONCE_STATIC_INIT
#define ERROR_GEN_FAILURE