advapi32: Add tests for StartTrace().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2016-12-18 15:25:59 -06:00 committed by Alexandre Julliard
parent f900879d9e
commit 1bcd38f788
2 changed files with 93 additions and 0 deletions

View File

@ -20,12 +20,15 @@
#include <stdarg.h> #include <stdarg.h>
#include "initguid.h"
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winerror.h" #include "winerror.h"
#include "winnt.h" #include "winnt.h"
#include "winreg.h" #include "winreg.h"
#include "sddl.h" #include "sddl.h"
#include "wmistr.h"
#include "evntrace.h"
#include "wine/test.h" #include "wine/test.h"
@ -1143,6 +1146,92 @@ static void cleanup_eventlog(void)
ok(bret, "Expected MoveFileEx to succeed: %d\n", GetLastError()); 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) START_TEST(eventlog)
{ {
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
@ -1172,4 +1261,7 @@ START_TEST(eventlog)
test_autocreation(); test_autocreation();
cleanup_eventlog(); cleanup_eventlog();
} }
/* Trace tests */
test_start_trace();
} }

View File

@ -236,6 +236,7 @@ typedef struct _EVENT_TRACE_PROPERTIES
ULONG MaximumFileSize; ULONG MaximumFileSize;
ULONG LogFileMode; ULONG LogFileMode;
ULONG FlushTimer; ULONG FlushTimer;
ULONG EnableFlags;
LONG AgeLimit; LONG AgeLimit;
ULONG NumberOfBuffers; ULONG NumberOfBuffers;
ULONG FreeBuffers; ULONG FreeBuffers;