advapi32/tests: Add some basic eventlog tests.
[wine/wine-gecko.git] / dlls / advapi32 / tests / eventlog.c
blob244a805e53377734d7ccda8513f5982c4aba404e
1 /*
2 * Unit tests for Event Logging functions
4 * Copyright (c) 2009 Paul Vriens
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "winnt.h"
28 #include "wine/test.h"
30 static void test_open_close(void)
32 HANDLE handle;
33 BOOL ret;
35 SetLastError(0xdeadbeef);
36 ret = CloseEventLog(NULL);
37 todo_wine
39 ok(!ret, "Expected failure\n");
40 ok(GetLastError() == ERROR_INVALID_HANDLE ||
41 GetLastError() == ERROR_NOACCESS, /* W2K */
42 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
45 SetLastError(0xdeadbeef);
46 handle = OpenEventLogA(NULL, NULL);
47 todo_wine
49 ok(handle == NULL, "Didn't expect a handle\n");
50 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
53 SetLastError(0xdeadbeef);
54 handle = OpenEventLogA("IDontExist", NULL);
55 todo_wine
57 ok(handle == NULL, "Didn't expect a handle\n");
58 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
61 SetLastError(0xdeadbeef);
62 handle = OpenEventLogA("IDontExist", "deadbeef");
63 todo_wine
65 ok(handle == NULL, "Didn't expect a handle\n");
66 ok(GetLastError() == RPC_S_SERVER_UNAVAILABLE ||
67 GetLastError() == RPC_S_INVALID_NET_ADDR, /* Some Vista and Win7 */
68 "Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError());
71 /* This one opens the Application log */
72 handle = OpenEventLogA(NULL, "deadbeef");
73 ok(handle != NULL, "Expected a handle\n");
74 ret = CloseEventLog(handle);
75 ok(ret, "Expected success\n");
76 /* Close a second time */
77 SetLastError(0xdeadbeef);
78 ret = CloseEventLog(handle);
79 todo_wine
81 ok(!ret, "Expected failure\n");
82 ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
85 handle = OpenEventLogA(NULL, "Application");
86 ok(handle != NULL, "Expected a handle\n");
87 CloseEventLog(handle);
90 START_TEST(eventlog)
92 SetLastError(0xdeadbeef);
93 CloseEventLog(NULL);
94 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
96 win_skip("Event log functions are not implemented\n");
97 return;
100 /* Parameters only */
101 test_open_close();