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: test1.c
8**
9** Purpose: Test for CreateEvent. Create an event, ensure the
10** HANDLE is valid. Then check to ensure that the object is in the
11** signaled state. Close the HANDLE and done.
12**
13**
14**=========================================================*/
15
16/*
17 Note: From the rotor_pal documentation:
18
19 lpEventAttributes will always be NULL, bManualReset can be either
20 TRUE or FALSE, bInitialState can be either TRUE or FALSE, the lpName
21 may be non-NULL
22
23*/
24
25
26#include <palsuite.h>
27
28BOOL CreateEventTest()
29{
30 BOOL bRet = FALSE;
31 DWORD dwRet = 0;
32
33 LPSECURITY_ATTRIBUTES lpEventAttributes = NULL;
34 BOOL bManualReset = TRUE;
35 BOOL bInitialState = TRUE;
36
37 /* Call CreateEvent, and check to ensure the returned HANDLE is a
38 valid event HANDLE
39 */
40
41 HANDLE hEvent = CreateEvent( lpEventAttributes,
42 bManualReset,
43 bInitialState,
44 NULL);
45
46 if (hEvent != NULL)
47 {
48 /* Wait for the Object (for 0 time) and ensure that it returns
49 the value indicating that the event is signaled.
50 */
51 dwRet = WaitForSingleObject(hEvent,0);
52
53 if (dwRet != WAIT_OBJECT_0)
54 {
55 Trace("CreateEventTest:WaitForSingleObject failed (%x)\n", GetLastError());
56 }
57 else
58 {
59 /* If we make it here, and CloseHandle succeeds, then the
60 entire test has passed. Otherwise bRet will still show
61 failure
62 */
63 bRet = CloseHandle(hEvent);
64
65 if (!bRet)
66 {
67 Trace("CreateEventTest:CloseHandle failed (%x)\n", GetLastError());
68 }
69 }
70 }
71 else
72 {
73 Trace("CreateEventTest:CreateEvent failed (%x)\n", GetLastError());
74 }
75
76 return bRet;
77}
78
79int __cdecl main(int argc, char **argv)
80{
81
82 if(0 != (PAL_Initialize(argc, argv)))
83 {
84 return ( FAIL );
85 }
86
87 if(!CreateEventTest())
88 {
89 Fail ("Test failed\n");
90 }
91
92 PAL_Terminate();
93 return ( PASS );
94
95}
96