| 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 CreateEvent. 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 | |
| 16 | #include <palsuite.h> |
| 17 | |
| 18 | BOOL 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 | /* Create an event with the Initial State set to FALSE */ |
| 28 | |
| 29 | HANDLE hEvent = CreateEvent( lpEventAttributes, |
| 30 | bManualReset, |
| 31 | bInitialState, |
| 32 | NULL); |
| 33 | |
| 34 | if (hEvent != NULL) |
| 35 | { |
| 36 | /* This should ensure that the object is reset, or |
| 37 | non-signaled. |
| 38 | */ |
| 39 | |
| 40 | dwRet = WaitForSingleObject(hEvent,0); |
| 41 | |
| 42 | if (dwRet != WAIT_TIMEOUT) |
| 43 | { |
| 44 | Trace("CloseEventTest:WaitForSingleObject failed (%x)\n" , GetLastError()); |
| 45 | } |
| 46 | else |
| 47 | { |
| 48 | /* At this point, we've tested the function with success. |
| 49 | So long as the HANDLE can be closed, this test should |
| 50 | pass. |
| 51 | */ |
| 52 | |
| 53 | bRet = CloseHandle(hEvent); |
| 54 | |
| 55 | if (!bRet) |
| 56 | { |
| 57 | Trace("CloseEventTest:CloseHandle failed (%x)\n" , GetLastError()); |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | else |
| 62 | { |
| 63 | Trace("CloseEventTest:CreateEvent failed (%x)\n" , GetLastError()); |
| 64 | } |
| 65 | |
| 66 | return bRet; |
| 67 | } |
| 68 | |
| 69 | int __cdecl main(int argc, char **argv) |
| 70 | { |
| 71 | if(0 != (PAL_Initialize(argc, argv))) |
| 72 | { |
| 73 | return ( FAIL ); |
| 74 | } |
| 75 | |
| 76 | if(!CreateEventTest()) |
| 77 | { |
| 78 | Fail ("Test failed\n" ); |
| 79 | } |
| 80 | |
| 81 | PAL_Terminate(); |
| 82 | return ( PASS ); |
| 83 | |
| 84 | } |
| 85 | |