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
28 #include "wine/test.h"
30 static void test_open_close(void)
35 SetLastError(0xdeadbeef);
36 ret = CloseEventLog(NULL);
37 ok(!ret, "Expected failure\n");
38 ok(GetLastError() == ERROR_INVALID_HANDLE ||
39 GetLastError() == ERROR_NOACCESS, /* W2K */
40 "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
42 SetLastError(0xdeadbeef);
43 handle = OpenEventLogA(NULL, NULL);
44 ok(handle == NULL, "Didn't expect a handle\n");
45 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
47 SetLastError(0xdeadbeef);
48 handle = OpenEventLogA("IDontExist", NULL);
49 ok(handle == NULL, "Didn't expect a handle\n");
50 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
52 SetLastError(0xdeadbeef);
53 handle = OpenEventLogA("IDontExist", "deadbeef");
54 ok(handle == NULL, "Didn't expect a handle\n");
55 ok(GetLastError() == RPC_S_SERVER_UNAVAILABLE ||
56 GetLastError() == RPC_S_INVALID_NET_ADDR, /* Some Vista and Win7 */
57 "Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError());
59 /* This one opens the Application log */
60 handle = OpenEventLogA(NULL, "deadbeef");
61 ok(handle != NULL, "Expected a handle\n");
62 ret = CloseEventLog(handle);
63 ok(ret, "Expected success\n");
64 /* Close a second time */
65 SetLastError(0xdeadbeef);
66 ret = CloseEventLog(handle);
69 ok(!ret, "Expected failure\n");
70 ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
73 /* Empty servername should be read as local server */
74 handle = OpenEventLogA("", "Application");
75 ok(handle != NULL, "Expected a handle\n");
76 CloseEventLog(handle);
78 handle = OpenEventLogA(NULL, "Application");
79 ok(handle != NULL, "Expected a handle\n");
80 CloseEventLog(handle);
85 SetLastError(0xdeadbeef);
87 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
89 win_skip("Event log functions are not implemented\n");