From 452b59bb4f6efeb2ecc9fd36c2b2d700adecfe0a Mon Sep 17 00:00:00 2001 From: Daniel Lehman Date: Sat, 23 Dec 2023 09:39:26 -0800 Subject: [PATCH] advapi32/tests: Add some more EventLog tests. --- dlls/advapi32/tests/eventlog.c | 50 ++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/dlls/advapi32/tests/eventlog.c b/dlls/advapi32/tests/eventlog.c index 3dfb3c50542..2f6c2bf05b6 100644 --- a/dlls/advapi32/tests/eventlog.c +++ b/dlls/advapi32/tests/eventlog.c @@ -1347,8 +1347,8 @@ static void test_eventlog_start(void) { BOOL ret, found; HANDLE handle, handle2; - EVENTLOGRECORD *record; - DWORD size, count, read, needed; + EVENTLOGRECORD *record, *record2; + DWORD size, size2, count, count2, read, needed; WCHAR *sourcename, *computername, *localcomputer; char *sourcenameA, *computernameA, *localcomputerA; @@ -1547,6 +1547,14 @@ static void test_eventlog_start(void) todo_wine 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 { ret = read_record(handle, EVENTLOG_SEEK_READ | EVENTLOG_FORWARDS_READ, 2, &record, &size); ok(ret, "Expected success : %ld\n", GetLastError()); @@ -1603,6 +1611,44 @@ static void test_eventlog_start(void) } 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); }