Paul Vriens : advapi32/tests: Add some GetEventLogInformation tests.

Alexandre Julliard julliard at winehq.org
Wed Oct 28 10:12:24 CDT 2009


Module: wine
Branch: master
Commit: 400d62167f2aa9a4ff82aa07dd0ec5bbb42e1914
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=400d62167f2aa9a4ff82aa07dd0ec5bbb42e1914

Author: Paul Vriens <Paul.Vriens.Wine at gmail.com>
Date:   Wed Oct 28 10:05:39 2009 +0100

advapi32/tests: Add some GetEventLogInformation tests.

---

 dlls/advapi32/tests/eventlog.c |   72 ++++++++++++++++++++++++++++++++++++++++
 include/winbase.h              |   10 +++++
 2 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/dlls/advapi32/tests/eventlog.c b/dlls/advapi32/tests/eventlog.c
index 2823f17..51d798b 100644
--- a/dlls/advapi32/tests/eventlog.c
+++ b/dlls/advapi32/tests/eventlog.c
@@ -27,6 +27,15 @@
 
 #include "wine/test.h"
 
+static BOOL (WINAPI *pGetEventLogInformation)(HANDLE,DWORD,LPVOID,DWORD,LPDWORD);
+
+static void init_function_pointers(void)
+{
+    HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
+
+    pGetEventLogInformation = (void*)GetProcAddress(hadvapi32, "GetEventLogInformation");
+}
+
 static void test_open_close(void)
 {
     HANDLE handle;
@@ -80,6 +89,66 @@ static void test_open_close(void)
     CloseEventLog(handle);
 }
 
+static void test_info(void)
+{
+    HANDLE handle;
+    BOOL ret;
+    DWORD needed;
+    EVENTLOG_FULL_INFORMATION efi;
+
+    if (!pGetEventLogInformation)
+    {
+        /* NT4 */
+        skip("GetEventLogInformation is not available\n");
+        return;
+    }
+    SetLastError(0xdeadbeef);
+    ret = pGetEventLogInformation(NULL, 1, NULL, 0, NULL);
+    ok(!ret, "Expected failure\n");
+    ok(GetLastError() == ERROR_INVALID_LEVEL, "Expected ERROR_INVALID_LEVEL, got %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pGetEventLogInformation(NULL, EVENTLOG_FULL_INFO, NULL, 0, NULL);
+    ok(!ret, "Expected failure\n");
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
+
+    handle = OpenEventLogA(NULL, "Application");
+
+    SetLastError(0xdeadbeef);
+    ret = pGetEventLogInformation(handle, EVENTLOG_FULL_INFO, NULL, 0, NULL);
+    ok(!ret, "Expected failure\n");
+    ok(GetLastError() == RPC_X_NULL_REF_POINTER, "Expected RPC_X_NULL_REF_POINTER, got %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pGetEventLogInformation(handle, EVENTLOG_FULL_INFO, NULL, 0, &needed);
+    ok(!ret, "Expected failure\n");
+    ok(GetLastError() == RPC_X_NULL_REF_POINTER, "Expected RPC_X_NULL_REF_POINTER, got %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ret = pGetEventLogInformation(handle, EVENTLOG_FULL_INFO, (LPVOID)&efi, 0, NULL);
+    ok(!ret, "Expected failure\n");
+    ok(GetLastError() == RPC_X_NULL_REF_POINTER, "Expected RPC_X_NULL_REF_POINTER, got %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    needed = 0xdeadbeef;
+    efi.dwFull = 0xdeadbeef;
+    ret = pGetEventLogInformation(handle, EVENTLOG_FULL_INFO, (LPVOID)&efi, 0, &needed);
+    ok(!ret, "Expected failure\n");
+    ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
+    ok(needed == sizeof(EVENTLOG_FULL_INFORMATION), "Expected sizeof(EVENTLOG_FULL_INFORMATION), got %d\n", needed);
+    ok(efi.dwFull == 0xdeadbeef, "Expected no change to the dwFull member\n");
+
+    /* Not that we care, but on success last error is set to ERROR_IO_PENDING */
+    efi.dwFull = 0xdeadbeef;
+    needed *= 2;
+    ret = pGetEventLogInformation(handle, EVENTLOG_FULL_INFO, (LPVOID)&efi, needed, &needed);
+    ok(ret, "Expected succes\n");
+    ok(needed == sizeof(EVENTLOG_FULL_INFORMATION), "Expected sizeof(EVENTLOG_FULL_INFORMATION), got %d\n", needed);
+    ok(efi.dwFull == 0 || efi.dwFull == 1, "Expected 0 (not full) or 1 (full), got %d\n", efi.dwFull);
+
+    CloseEventLog(handle);
+}
+
 START_TEST(eventlog)
 {
     SetLastError(0xdeadbeef);
@@ -90,6 +159,9 @@ START_TEST(eventlog)
         return;
     }
 
+    init_function_pointers();
+
     /* Parameters only */
     test_open_close();
+    test_info();
 }
diff --git a/include/winbase.h b/include/winbase.h
index 8117430..0b4ee17 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -1223,6 +1223,15 @@ typedef struct tagHW_PROFILE_INFOW {
 DECL_WINELIB_TYPE_AW(HW_PROFILE_INFO)
 DECL_WINELIB_TYPE_AW(LPHW_PROFILE_INFO)
 
+/* Event Logging */
+
+#define EVENTLOG_FULL_INFO          0
+
+typedef struct _EVENTLOG_FULL_INFORMATION {
+    DWORD dwFull;
+} EVENTLOG_FULL_INFORMATION, *LPEVENTLOG_FULL_INFORMATION;
+
+
 /* Stream data structures and defines */
 /*the types of backup data -- WIN32_STREAM_ID.dwStreamId below*/
 #define BACKUP_INVALID        0
@@ -1615,6 +1624,7 @@ WINBASEAPI DWORD       WINAPI GetEnvironmentVariableA(LPCSTR,LPSTR,DWORD);
 WINBASEAPI DWORD       WINAPI GetEnvironmentVariableW(LPCWSTR,LPWSTR,DWORD);
 #define                       GetEnvironmentVariable WINELIB_NAME_AW(GetEnvironmentVariable)
 WINBASEAPI UINT        WINAPI GetErrorMode(void);
+WINADVAPI  BOOL        WINAPI GetEventLogInformation(HANDLE,DWORD,LPVOID,DWORD,LPDWORD);
 WINBASEAPI BOOL        WINAPI GetExitCodeProcess(HANDLE,LPDWORD);
 WINBASEAPI BOOL        WINAPI GetExitCodeThread(HANDLE,LPDWORD);
 WINBASEAPI DWORD       WINAPI GetFileAttributesA(LPCSTR);




More information about the wine-cvs mailing list