Commit 452b59bb authored by Daniel Lehman's avatar Daniel Lehman Committed by Alexandre Julliard

advapi32/tests: Add some more EventLog tests.

parent 8c91e484
...@@ -1347,8 +1347,8 @@ static void test_eventlog_start(void) ...@@ -1347,8 +1347,8 @@ static void test_eventlog_start(void)
{ {
BOOL ret, found; BOOL ret, found;
HANDLE handle, handle2; HANDLE handle, handle2;
EVENTLOGRECORD *record; EVENTLOGRECORD *record, *record2;
DWORD size, count, read, needed; DWORD size, size2, count, count2, read, needed;
WCHAR *sourcename, *computername, *localcomputer; WCHAR *sourcename, *computername, *localcomputer;
char *sourcenameA, *computernameA, *localcomputerA; char *sourcenameA, *computernameA, *localcomputerA;
...@@ -1547,6 +1547,14 @@ static void test_eventlog_start(void) ...@@ -1547,6 +1547,14 @@ static void test_eventlog_start(void)
todo_wine todo_wine
ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError()); ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
count = 0xdeadbeef;
ret = GetNumberOfEventLogRecords(handle, &count);
ok(ret, "Expected success : %ld\n", GetLastError());
ret = read_record(handle, EVENTLOG_SEEK_READ | EVENTLOG_FORWARDS_READ, count + 1, &record, &size);
ok(!ret, "Expected failure\n");
todo_wine
ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
todo_wine { todo_wine {
ret = read_record(handle, EVENTLOG_SEEK_READ | EVENTLOG_FORWARDS_READ, 2, &record, &size); ret = read_record(handle, EVENTLOG_SEEK_READ | EVENTLOG_FORWARDS_READ, 2, &record, &size);
ok(ret, "Expected success : %ld\n", GetLastError()); ok(ret, "Expected success : %ld\n", GetLastError());
...@@ -1603,6 +1611,44 @@ static void test_eventlog_start(void) ...@@ -1603,6 +1611,44 @@ static void test_eventlog_start(void)
} }
CloseEventLog(handle); CloseEventLog(handle);
/* reading same log with different handles */
handle = OpenEventLogW(0, L"System");
handle2 = OpenEventLogW(0, L"SYSTEM");
todo_wine {
ret = read_record(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ, 0, &record, &size);
ok(ret, "Expected success : %ld\n", GetLastError());
ok(record->RecordNumber == 1, "Expected 1, got %lu\n", record->RecordNumber);
ret = read_record(handle2, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ, 0, &record, &size);
ok(ret, "Expected success : %ld\n", GetLastError());
ok(record->RecordNumber == 1, "Expected 1, got %lu\n", record->RecordNumber);
}
CloseEventLog(handle2);
CloseEventLog(handle);
/* using source name */
size2 = size;
record2 = malloc(size2);
handle = OpenEventLogW(0, L"System");
handle2 = OpenEventLogW(0, L"EventLog");
todo_wine {
ret = read_record(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ, 0, &record, &size);
ok(ret, "Expected success : %ld\n", GetLastError());
ret = read_record(handle2, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ, 0, &record2, &size2);
ok(ret, "Expected success : %ld\n", GetLastError());
}
ok(size == size2, "Expected %lu, got %lu\n", size, size2);
ok(!memcmp(record, record2, min(size, size2)), "Records miscompare\n");
count = 0xdeadbeef;
count2 = 0xdeadbeef;
ret = GetNumberOfEventLogRecords(handle, &count);
ok(ret, "Expected success : %ld\n", GetLastError());
ret = GetNumberOfEventLogRecords(handle2, &count2);
ok(ret, "Expected success : %ld\n", GetLastError());
ok(count == count2, "Expected %lu, got %lu\n", count, count2);
CloseEventLog(handle2);
CloseEventLog(handle);
free(record2);
free(record); free(record);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment