diff --git a/rostests/apitests/advapi32/CMakeLists.txt b/rostests/apitests/advapi32/CMakeLists.txt index d99be934a46..6a86af353a9 100644 --- a/rostests/apitests/advapi32/CMakeLists.txt +++ b/rostests/apitests/advapi32/CMakeLists.txt @@ -2,6 +2,7 @@ list(APPEND SOURCE CreateService.c DuplicateTokenEx.c + eventlog.c HKEY_CLASSES_ROOT.c IsTextUnicode.c LockDatabase.c diff --git a/rostests/apitests/advapi32/eventlog.c b/rostests/apitests/advapi32/eventlog.c new file mode 100644 index 00000000000..4125ef6d4e3 --- /dev/null +++ b/rostests/apitests/advapi32/eventlog.c @@ -0,0 +1,91 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Supplemental tests for Winetests' Event Logging functions + * PROGRAMMER: Hermes Belusca-Maito + */ + +#include + +#define WIN32_NO_STATUS +#include + +START_TEST(eventlog) +{ + static struct + { + /* Input */ + ULONG MaxDataSize; + + /* Output for Windows <= 2k3 / Windows Vista+ */ + struct + { + BOOL Success; + DWORD LastError; + } Result[2]; + } Tests[] = + { + /* + * Tests for the different RPC boundaries on Windows. + * See also the "ReportEvent" API on MSDN, section "Return value", at: + * https://msdn.microsoft.com/en-us/library/windows/desktop/aa363679(v=vs.85).aspx + * for more details. + */ + { 0xF000, { {TRUE, ERROR_SUCCESS}, {TRUE , ERROR_SUCCESS} } }, + { 0xF001, { {TRUE, ERROR_SUCCESS}, {FALSE, RPC_S_INVALID_BOUND} } }, + + { 0x3FF66, { {TRUE, ERROR_SUCCESS}, {FALSE, RPC_S_INVALID_BOUND} } }, + { 0x3FF67, { {TRUE, ERROR_SUCCESS}, {FALSE, RPC_S_INVALID_BOUND} } }, + { 0x3FF68, { {TRUE, ERROR_SUCCESS}, {FALSE, RPC_S_INVALID_BOUND} } }, + + /* Show that the maximum data size for an event can be as big as 0x3FFFF */ + { 0x3FFFE, { {TRUE, ERROR_SUCCESS /* or ERROR_INVALID_PARAMETER on Win2k3 */}, {FALSE, RPC_S_INVALID_BOUND} } }, + { 0x3FFFF, { {TRUE, ERROR_SUCCESS /* or ERROR_INVALID_PARAMETER on Win2k3 */}, {FALSE, RPC_S_INVALID_BOUND} } }, + { 0x40000, { {FALSE, RPC_X_BAD_STUB_DATA}, {FALSE, RPC_S_INVALID_BOUND} } }, + }; + + UINT i; + BOOL Success; + DWORD LastError; + HANDLE hEventLog; + PVOID Data; + + /* We use the "Application" log for the different tests! */ + hEventLog = OpenEventLogW(NULL, L"Application"); + ok(hEventLog != NULL, "OpenEventLogW(NULL, L\"Application\") failed with error %lu\n", GetLastError()); + if (!hEventLog) + return; + + for (i = 0; i < ARRAYSIZE(Tests); ++i) + { + Data = HeapAlloc(GetProcessHeap(), 0, Tests[i].MaxDataSize); + ok(Data != NULL, "Failed to allocate memory for data of size %lu\n", Tests[i].MaxDataSize); + if (Data) + { + RtlFillMemory(Data, Tests[i].MaxDataSize, 0xCA); + + ClearEventLog(hEventLog, NULL); + + SetLastError(ERROR_SUCCESS); + Success = ReportEventW(hEventLog, EVENTLOG_INFORMATION_TYPE, 1, 1, NULL, 0, Tests[i].MaxDataSize, NULL, Data); + LastError = GetLastError(); + /* Small adjustment */ + if (LastError == ERROR_ENVVAR_NOT_FOUND) + LastError = ERROR_SUCCESS; + + ok((LastError == Tests[i].Result[0].LastError) || + broken(LastError == ERROR_INVALID_PARAMETER /* For Win2k3, see above */) || + broken(LastError == Tests[i].Result[1].LastError /* For Vista+ */), + "ReportEventW(%u) last error was %lu, expected %lu\n", i, LastError, Tests[i].Result[0].LastError); + + ok((Success == Tests[i].Result[0].Success) || broken(Success == Tests[i].Result[1].Success /* For Vista+ */), + "ReportEventW(%u) returned 0x%x, expected %s\n", i, Success, (Tests[i].Result[0].Success ? "TRUE" : "FALSE")); + + HeapFree(GetProcessHeap(), 0, Data); + } + } + + ClearEventLog(hEventLog, NULL); + + CloseEventLog(hEventLog); +} diff --git a/rostests/apitests/advapi32/testlist.c b/rostests/apitests/advapi32/testlist.c index c93ef9bbbca..8ca23b987ee 100644 --- a/rostests/apitests/advapi32/testlist.c +++ b/rostests/apitests/advapi32/testlist.c @@ -5,6 +5,7 @@ extern void func_CreateService(void); extern void func_DuplicateTokenEx(void); +extern void func_eventlog(void); extern void func_HKEY_CLASSES_ROOT(void); extern void func_IsTextUnicode(void); extern void func_LockDatabase(void); @@ -18,6 +19,7 @@ const struct test winetest_testlist[] = { { "CreateService", func_CreateService }, { "DuplicateTokenEx", func_DuplicateTokenEx }, + { "eventlog", func_eventlog }, { "HKEY_CLASSES_ROOT", func_HKEY_CLASSES_ROOT }, { "IsTextUnicode" , func_IsTextUnicode }, { "LockDatabase" , func_LockDatabase },