3 #include <winpr/synch.h>
5 int TestSynchEvent(
int argc,
char* argv[])
12 printf(
"ResetEvent(NULL) unexpectedly succeeded\n");
18 printf(
"SetEvent(NULL) unexpectedly succeeded\n");
22 event = CreateEvent(NULL, TRUE, TRUE, NULL);
26 printf(
"CreateEvent failure\n");
30 if (WaitForSingleObject(event, INFINITE) != WAIT_OBJECT_0)
32 printf(
"WaitForSingleObject failure 1\n");
36 if (!ResetEvent(event))
38 printf(
"ResetEvent failure with signaled event object\n");
42 if (WaitForSingleObject(event, 0) != WAIT_TIMEOUT)
44 printf(
"WaitForSingleObject failure 2\n");
48 if (!ResetEvent(event))
51 printf(
"ResetEvent failure with nonsignaled event object\n");
57 printf(
"SetEvent failure with nonsignaled event object\n");
61 if (WaitForSingleObject(event, 0) != WAIT_OBJECT_0)
63 printf(
"WaitForSingleObject failure 3\n");
67 for (
int i = 0; i < 10000; i++)
71 printf(
"SetEvent failure with signaled event object (i = %d)\n", i);
76 if (!ResetEvent(event))
78 printf(
"ResetEvent failure after multiple SetEvent calls\n");
85 if (WaitForSingleObject(event, 0) != WAIT_TIMEOUT)
87 printf(
"WaitForSingleObject failure 4\n");
91 (void)CloseHandle(event);