[SHELL32_APITEST]: Add more tests to see how IShellLink::Get/SetIconLocation interact...
[reactos.git] / rostests / apitests / advapi32 / eventlog.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: Supplemental tests for Winetests' Event Logging functions
5 * PROGRAMMER: Hermes Belusca-Maito
6 */
7
8 #include <apitest.h>
9
10 #define WIN32_NO_STATUS
11 #include <winbase.h>
12
13 START_TEST(eventlog)
14 {
15 static struct
16 {
17 /* Input */
18 ULONG MaxDataSize;
19
20 /* Output for Windows <= 2k3 | Windows Vista+ (or "old" ReactOS) */
21 struct
22 {
23 BOOL Success;
24 DWORD LastError;
25 } Result[2];
26 } Tests[] =
27 {
28 /*
29 * Tests for the different RPC boundaries on Windows.
30 * See also the "ReportEvent" API on MSDN, section "Return value", at:
31 * https://msdn.microsoft.com/en-us/library/windows/desktop/aa363679(v=vs.85).aspx
32 * for more details.
33 */
34 { 0xF000, { {TRUE, ERROR_SUCCESS}, {TRUE , ERROR_SUCCESS} } },
35 { 0xF001, { {TRUE, ERROR_SUCCESS}, {FALSE, RPC_S_INVALID_BOUND} } },
36
37 { 0x3FF66, { {TRUE, ERROR_SUCCESS}, {FALSE, RPC_S_INVALID_BOUND} } },
38 { 0x3FF67, { {TRUE, ERROR_SUCCESS}, {FALSE, RPC_S_INVALID_BOUND} } },
39 { 0x3FF68, { {TRUE, ERROR_SUCCESS}, {FALSE, RPC_S_INVALID_BOUND} } },
40
41 /* Show that the maximum data size for an event can be as big as 0x3FFFF */
42 { 0x3FFFE, { {TRUE, ERROR_SUCCESS /* or FALSE, ERROR_INVALID_PARAMETER on Win2k3 */}, {FALSE, RPC_S_INVALID_BOUND} } },
43 { 0x3FFFF, { {TRUE, ERROR_SUCCESS /* or FALSE, ERROR_INVALID_PARAMETER on Win2k3 */}, {FALSE, RPC_S_INVALID_BOUND} } },
44 { 0x40000, { {FALSE, RPC_X_BAD_STUB_DATA}, {FALSE, RPC_S_INVALID_BOUND} } },
45 };
46
47 UINT i;
48 BOOL Success;
49 DWORD LastError;
50 HANDLE hEventLog;
51 PVOID Data;
52
53 /* We use the "Application" log for the different tests! */
54 hEventLog = OpenEventLogW(NULL, L"Application");
55 ok(hEventLog != NULL, "OpenEventLogW(NULL, L\"Application\") failed with error %lu\n", GetLastError());
56 if (!hEventLog)
57 return;
58
59 for (i = 0; i < ARRAYSIZE(Tests); ++i)
60 {
61 Data = HeapAlloc(GetProcessHeap(), 0, Tests[i].MaxDataSize);
62 ok(Data != NULL, "Failed to allocate memory for data of size %lu\n", Tests[i].MaxDataSize);
63 if (Data)
64 {
65 RtlFillMemory(Data, Tests[i].MaxDataSize, 0xCA);
66
67 ClearEventLog(hEventLog, NULL);
68
69 SetLastError(ERROR_SUCCESS);
70 Success = ReportEventW(hEventLog, EVENTLOG_INFORMATION_TYPE, 1, 1, NULL, 0, Tests[i].MaxDataSize, NULL, Data);
71 LastError = GetLastError();
72 /* Small adjustment */
73 if (LastError == ERROR_ENVVAR_NOT_FOUND)
74 LastError = ERROR_SUCCESS;
75
76 ok( ( (Success == Tests[i].Result[0].Success) && (LastError == Tests[i].Result[0].LastError) ) ||
77 broken( (Success == FALSE) && (LastError == ERROR_INVALID_PARAMETER) /* For Win2k3, see above */) // ||
78 // broken( (Success == Tests[i].Result[1].Success) && (LastError == Tests[i].Result[1].LastError) /* For Vista+ */)
79 ,
80 "ReportEventW(%u) returned 0x%x with last error %lu, expected %s with last error %lu\n",
81 i, Success, LastError, (Tests[i].Result[0].Success ? "TRUE" : "FALSE"), Tests[i].Result[0].LastError);
82
83 HeapFree(GetProcessHeap(), 0, Data);
84 }
85 }
86
87 ClearEventLog(hEventLog, NULL);
88
89 CloseEventLog(hEventLog);
90 }