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