Author: hbelusca
Date: Fri Aug 12 12:15:24 2016
New Revision: 72207

URL: http://svn.reactos.org/svn/reactos?rev=72207&view=rev
Log:
[ADVAPI32_APITEST]: Add some supplemental tests for Winetests' Event Logging 
functions, testing different RPC limits related to the maximum size of the data 
buffer in events.
CORE-11838 CORE-11839

Added:
    trunk/rostests/apitests/advapi32/eventlog.c   (with props)
Modified:
    trunk/rostests/apitests/advapi32/CMakeLists.txt
    trunk/rostests/apitests/advapi32/testlist.c

Modified: trunk/rostests/apitests/advapi32/CMakeLists.txt
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/CMakeLists.txt?rev=72207&r1=72206&r2=72207&view=diff
==============================================================================
--- trunk/rostests/apitests/advapi32/CMakeLists.txt     [iso-8859-1] (original)
+++ trunk/rostests/apitests/advapi32/CMakeLists.txt     [iso-8859-1] Fri Aug 12 
12:15:24 2016
@@ -2,6 +2,7 @@
 list(APPEND SOURCE
     CreateService.c
     DuplicateTokenEx.c
+    eventlog.c
     HKEY_CLASSES_ROOT.c
     IsTextUnicode.c
     LockDatabase.c

Added: trunk/rostests/apitests/advapi32/eventlog.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/eventlog.c?rev=72207
==============================================================================
--- trunk/rostests/apitests/advapi32/eventlog.c (added)
+++ trunk/rostests/apitests/advapi32/eventlog.c [iso-8859-1] Fri Aug 12 
12:15:24 2016
@@ -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 <apitest.h>
+
+#define WIN32_NO_STATUS
+#include <winbase.h>
+
+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);
+}

Propchange: trunk/rostests/apitests/advapi32/eventlog.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/rostests/apitests/advapi32/testlist.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/advapi32/testlist.c?rev=72207&r1=72206&r2=72207&view=diff
==============================================================================
--- trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/advapi32/testlist.c [iso-8859-1] Fri Aug 12 
12:15:24 2016
@@ -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 @@
 {
     { "CreateService", func_CreateService },
     { "DuplicateTokenEx", func_DuplicateTokenEx },
+    { "eventlog", func_eventlog },
     { "HKEY_CLASSES_ROOT", func_HKEY_CLASSES_ROOT },
     { "IsTextUnicode" , func_IsTextUnicode },
     { "LockDatabase" , func_LockDatabase },


Reply via email to