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