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 SetEvent. Create an Event and then set |
10 | ** this event, checking the return value. Ensure that it returns |
11 | ** positive. |
12 | ** |
13 | ** |
14 | **=========================================================*/ |
15 | |
16 | #include <palsuite.h> |
17 | |
18 | BOOL SetEventTest() |
19 | { |
20 | int bRet = 0; |
21 | DWORD dwRet = 0; |
22 | |
23 | LPSECURITY_ATTRIBUTES lpEventAttributes = 0; |
24 | BOOL bManualReset = TRUE; |
25 | BOOL bInitialState = FALSE; |
26 | |
27 | /* Create an event which we can use with SetEvent */ |
28 | HANDLE hEvent = CreateEvent( lpEventAttributes, |
29 | bManualReset, bInitialState, NULL); |
30 | |
31 | if (hEvent != INVALID_HANDLE_VALUE) |
32 | { |
33 | dwRet = WaitForSingleObject(hEvent,0); |
34 | |
35 | if (dwRet != WAIT_TIMEOUT) |
36 | { |
37 | Trace("SetEventTest:WaitForSingleObject failed (%x)\n" , GetLastError()); |
38 | } |
39 | else |
40 | { |
41 | /* Set the event to the previously created event and check |
42 | the return value. |
43 | */ |
44 | bRet = SetEvent(hEvent); |
45 | |
46 | if (!bRet) |
47 | { |
48 | Trace("SetEventTest:SetEvent failed (%x)\n" , GetLastError()); |
49 | } |
50 | else |
51 | { |
52 | dwRet = WaitForSingleObject(hEvent,0); |
53 | |
54 | if (dwRet != WAIT_OBJECT_0) |
55 | { |
56 | Trace("SetEventTest:WaitForSingleObject failed (%x)\n" , GetLastError()); |
57 | } |
58 | else |
59 | { |
60 | dwRet = CloseHandle(hEvent); |
61 | |
62 | if (!dwRet) |
63 | { |
64 | Trace("SetEventTest:CloseHandle failed (%x)\n" , GetLastError()); |
65 | } |
66 | } |
67 | } |
68 | } |
69 | } |
70 | else |
71 | { |
72 | Trace("SetEventTest:CreateEvent failed (%x)\n" , GetLastError()); |
73 | } |
74 | |
75 | return bRet; |
76 | } |
77 | |
78 | |
79 | int __cdecl main(int argc, char **argv) |
80 | { |
81 | if(0 != (PAL_Initialize(argc, argv))) |
82 | { |
83 | return ( FAIL ); |
84 | } |
85 | |
86 | if(SetEventTest() == 0) |
87 | { |
88 | Fail ("Test failed\n" ); |
89 | } |
90 | |
91 | PAL_Terminate(); |
92 | return ( PASS ); |
93 | |
94 | } |
95 | |