Zebediah Figura : advapi32: Add tests for StartTrace().

Alexandre Julliard julliard at winehq.org
Tue Dec 20 16:23:24 CST 2016


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

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Sun Dec 18 15:25:59 2016 -0600

advapi32: Add tests for StartTrace().

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/advapi32/tests/eventlog.c | 92 ++++++++++++++++++++++++++++++++++++++++++
 include/evntrace.h             |  1 +
 2 files changed, 93 insertions(+)

diff --git a/dlls/advapi32/tests/eventlog.c b/dlls/advapi32/tests/eventlog.c
index 7daaeaf..d86a924 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"
 
@@ -1143,6 +1146,92 @@ static void cleanup_eventlog(void)
     ok(bret, "Expected MoveFileEx to succeed: %d\n", GetLastError());
 }
 
+static void test_start_trace(void)
+{
+    const char sessionname[] = "wine";
+    const char filepath[] = "wine.etl";
+    const char filepath2[] = "eniw.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 ||
+       ret == ERROR_INVALID_PARAMETER, /* XP and 2k3 */
+       "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;
+    /* XP creates a file we can't delete, so change the filepath to something else */
+    strcpy((char *)properties + properties->LogFileNameOffset, filepath2);
+
+    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 ||
+       ret == ERROR_SHARING_VIOLATION, /* 2k3 */
+       "Expected ERROR_ALREADY_EXISTS, got %d\n", ret);
+
+    /* clean up */
+    ControlTraceA(handle, sessionname, properties, EVENT_TRACE_CONTROL_STOP);
+    HeapFree(GetProcessHeap(), 0, properties);
+    DeleteFileA(filepath);
+}
+
 START_TEST(eventlog)
 {
     SetLastError(0xdeadbeef);
@@ -1172,4 +1261,7 @@ START_TEST(eventlog)
         test_autocreation();
         cleanup_eventlog();
     }
+
+    /* Trace tests */
+    test_start_trace();
 }
diff --git a/include/evntrace.h b/include/evntrace.h
index bb1ce03..5722b28 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;




More information about the wine-cvs mailing list