[PATCH] advapi32: Add tests for StartTrace().

Zebediah Figura z.figura12 at gmail.com
Mon Dec 12 23:27:25 CST 2016


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/advapi32/tests/eventlog.c | 84 ++++++++++++++++++++++++++++++++++++++++++
 include/evntrace.h             |  1 +
 2 files changed, 85 insertions(+)

diff --git a/dlls/advapi32/tests/eventlog.c b/dlls/advapi32/tests/eventlog.c
index 3ca59c3..7810a0c 100644
--- a/dlls/advapi32/tests/eventlog.c
+++ b/dlls/advapi32/tests/eventlog.c
@@ -20,12 +20,15 @@
 
 #include <stdarg.h>
 
+#include "initguid.h"
 #include "windef.h"
 #include "winbase.h"
 #include "winerror.h"
 #include "winnt.h"
 #include "winreg.h"
 #include "sddl.h"
+#include "wmistr.h"
+#include "evntrace.h"
 
 #include "wine/test.h"
 
@@ -1142,6 +1145,84 @@ static void cleanup_eventlog(void)
     ok(bret, "Expected MoveFileEx to succeed: %d\n", GetLastError());
 }
 
+static void test_start_trace(void)
+{
+    const char sessionname[] = "wine123";
+    const char filepath[] = "win.etl";
+    EVENT_TRACE_PROPERTIES *properties;
+    TRACEHANDLE handle;
+    LONG buffersize;
+    LONG ret;
+
+    buffersize = sizeof(EVENT_TRACE_PROPERTIES) + sizeof(sessionname) + sizeof(filepath);
+    properties = (EVENT_TRACE_PROPERTIES *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, buffersize);
+    properties->Wnode.BufferSize = buffersize;
+    properties->Wnode.Flags = WNODE_FLAG_TRACED_GUID;
+    properties->LogFileMode = EVENT_TRACE_FILE_MODE_NONE;
+    properties->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
+    properties->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + sizeof(sessionname);
+    strcpy((char *)properties + properties->LogFileNameOffset, filepath);
+
+    properties->Wnode.BufferSize = 0;
+    ret = StartTraceA(&handle, sessionname, properties);
+    todo_wine
+    ok(ret == ERROR_BAD_LENGTH, "Expected ERROR_BAD_LENGTH, got %d\n", ret);
+    properties->Wnode.BufferSize = buffersize;
+
+    ret = StartTraceA(&handle, "this name is too long", properties);
+    todo_wine
+    ok(ret == ERROR_BAD_LENGTH, "Expected ERROR_BAD_LENGTH, got %d\n", ret);
+
+    ret = StartTraceA(&handle, sessionname, NULL);
+    todo_wine
+    ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
+
+    ret = StartTraceA(NULL, sessionname, properties);
+    todo_wine
+    ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
+
+    properties->LogFileNameOffset = 1;
+    ret = StartTraceA(&handle, sessionname, properties);
+    todo_wine
+    ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
+    properties->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + sizeof(sessionname);
+
+    properties->LoggerNameOffset = 1;
+    ret = StartTraceA(&handle, sessionname, properties);
+    todo_wine
+    ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
+    properties->LoggerNameOffset = sizeof(EVENT_TRACE_PROPERTIES);
+
+    properties->LogFileMode = EVENT_TRACE_FILE_MODE_SEQUENTIAL | EVENT_TRACE_FILE_MODE_CIRCULAR;
+    ret = StartTraceA(&handle, sessionname, properties);
+    todo_wine
+    ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
+    properties->LogFileMode = EVENT_TRACE_FILE_MODE_NONE;
+
+    properties->Wnode.Guid = SystemTraceControlGuid;
+    ret = StartTraceA(&handle, sessionname, properties);
+    todo_wine
+    ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
+    properties->Wnode.Guid = (GUID){0};
+
+    properties->LogFileNameOffset = 0;
+    ret = StartTraceA(&handle, sessionname, properties);
+    todo_wine
+    ok(ret == ERROR_BAD_PATHNAME, "Expected ERROR_BAD_PATHNAME, got %d\n", ret);
+    properties->LogFileNameOffset = sizeof(EVENT_TRACE_PROPERTIES) + sizeof(sessionname);
+
+    ret = StartTraceA(&handle, sessionname, properties);
+    ok(ret == ERROR_SUCCESS, "Expected success, got %d\n", ret);
+
+    ret = StartTraceA(&handle, sessionname, properties);
+    todo_wine
+    ok(ret == ERROR_ALREADY_EXISTS, "Expected ERROR_ALREADY_EXISTS, got %d\n", ret);
+
+    /* clean up */
+    ControlTraceA(handle, sessionname, properties, EVENT_TRACE_CONTROL_STOP);
+    HeapFree(GetProcessHeap(), 0, properties);
+}
+
 START_TEST(eventlog)
 {
     SetLastError(0xdeadbeef);
@@ -1171,4 +1252,7 @@ START_TEST(eventlog)
         test_autocreation();
         cleanup_eventlog();
     }
+
+    /* Trace tests */
+    test_start_trace();
 }
diff --git a/include/evntrace.h b/include/evntrace.h
index 191f232..72442c4 100644
--- a/include/evntrace.h
+++ b/include/evntrace.h
@@ -236,6 +236,7 @@ typedef struct _EVENT_TRACE_PROPERTIES
     ULONG MaximumFileSize;
     ULONG LogFileMode;
     ULONG FlushTimer;
+    ULONG EnableFlags;
     LONG AgeLimit;
     ULONG NumberOfBuffers;
     ULONG FreeBuffers;
-- 
2.7.4




More information about the wine-patches mailing list