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);
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 ok(handle == NULL, "Didn't expect a handle\n");
48 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
50 SetLastError(0xdeadbeef);
51 handle = OpenEventLogA("IDontExist", NULL);
52 ok(handle == NULL, "Didn't expect a handle\n");
53 ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
55 SetLastError(0xdeadbeef);
56 handle = OpenEventLogA("IDontExist", "deadbeef");
57 ok(handle == NULL, "Didn't expect a handle\n");
58 ok(GetLastError() == RPC_S_SERVER_UNAVAILABLE ||
59 GetLastError() == RPC_S_INVALID_NET_ADDR, /* Some Vista and Win7 */
60 "Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError());
62 /* This one opens the Application log */
63 handle = OpenEventLogA(NULL, "deadbeef");
64 ok(handle != NULL, "Expected a handle\n");
65 ret = CloseEventLog(handle);
66 ok(ret, "Expected success\n");
67 /* Close a second time */
68 SetLastError(0xdeadbeef);
69 ret = CloseEventLog(handle);
72 ok(!ret, "Expected failure\n");
73 ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
76 /* Empty servername should be read as local server */
77 handle = OpenEventLogA("", "Application");
78 ok(handle != NULL, "Expected a handle\n");
79 CloseEventLog(handle);
81 handle = OpenEventLogA(NULL, "Application");
82 ok(handle != NULL, "Expected a handle\n");
83 CloseEventLog(handle);
88 SetLastError(0xdeadbeef);
90 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
92 win_skip("Event log functions are not implemented\n");