1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5/*============================================================
6**
7** Source: test2.c
8**
9** Purpose: Test for CreateEventW. Create the event with the
10** initial state being not signaled. Check to ensure that it
11** times out when the event is triggered.
12**
13**
14**=========================================================*/
15#define UNICODE
16#include <palsuite.h>
17
18BOOL CreateEventTest()
19{
20 BOOL bRet = FALSE;
21 DWORD dwRet = 0;
22
23 LPSECURITY_ATTRIBUTES lpEventAttributes = 0;
24 BOOL bManualReset = TRUE;
25 BOOL bInitialState = FALSE;
26
27
28 /* Create an event with the Initial State set to FALSE */
29
30 HANDLE hEvent = CreateEventW(lpEventAttributes,
31 bManualReset,
32 bInitialState,
33 NULL);
34
35 if (hEvent != NULL)
36 {
37 /* This should ensure that the object is reset, or
38 non-signaled.
39 */
40
41 dwRet = WaitForSingleObject(hEvent,0);
42
43 if (dwRet != WAIT_TIMEOUT)
44 {
45 Trace("CloseEventTest:WaitForSingleObject failed (%x)\n", GetLastError());
46 }
47 else
48 {
49 /* At this point, we've tested the function with success.
50 So long as the HANDLE can be closed, this test should
51 pass.
52 */
53
54 bRet = CloseHandle(hEvent);
55
56 if (!bRet)
57 {
58 Trace("CloseEventTest:CloseHandle failed (%x)\n", GetLastError());
59 }
60 }
61 }
62 else
63 {
64 Trace("CloseEventTest:CreateEvent failed (%x)\n", GetLastError());
65 }
66
67 return bRet;
68}
69
70int __cdecl main(int argc, char **argv)
71{
72 if(0 != (PAL_Initialize(argc, argv)))
73 {
74 return ( FAIL );
75 }
76
77 if(!CreateEventTest())
78 {
79 Fail ("Test failed\n");
80 }
81
82 PAL_Terminate();
83 return ( PASS );
84
85}
86