advapi32/test: Stop crash when ReadEventLog returns an unexpected error.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
60fa2d7aa5
commit
d0350eef1e
|
@ -909,6 +909,7 @@ static void test_readwrite(void)
|
||||||
|
|
||||||
/* Read all events from our created eventlog, one by one */
|
/* Read all events from our created eventlog, one by one */
|
||||||
handle = OpenEventLogA(NULL, eventlogname);
|
handle = OpenEventLogA(NULL, eventlogname);
|
||||||
|
ok(handle != NULL, "Failed to open Event Log, got %d\n", GetLastError());
|
||||||
i = 0;
|
i = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -924,14 +925,13 @@ static void test_readwrite(void)
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
|
ret = ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
|
||||||
0, buf, sizeof(EVENTLOGRECORD), &read, &needed);
|
0, buf, sizeof(EVENTLOGRECORD), &read, &needed);
|
||||||
if (!ret && GetLastError() == ERROR_HANDLE_EOF)
|
ok(!ret, "Expected failure\n");
|
||||||
|
if (!ret && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, buf);
|
HeapFree(GetProcessHeap(), 0, buf);
|
||||||
|
ok(GetLastError() == ERROR_HANDLE_EOF, "record %d, got %d\n", i, GetLastError());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ok(!ret, "Expected failure\n");
|
|
||||||
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
|
||||||
"Expected ERROR_INVALID_PARAMETER, got %d\n",GetLastError());
|
|
||||||
|
|
||||||
buf = HeapReAlloc(GetProcessHeap(), 0, buf, needed);
|
buf = HeapReAlloc(GetProcessHeap(), 0, buf, needed);
|
||||||
ret = ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
|
ret = ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
|
||||||
|
@ -1010,6 +1010,7 @@ static void test_readwrite(void)
|
||||||
|
|
||||||
/* Test clearing a real eventlog */
|
/* Test clearing a real eventlog */
|
||||||
handle = OpenEventLogA(NULL, eventlogname);
|
handle = OpenEventLogA(NULL, eventlogname);
|
||||||
|
ok(handle != NULL, "Failed to open Event Log, got %d\n", GetLastError());
|
||||||
|
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = ClearEventLogA(handle, NULL);
|
ret = ClearEventLogA(handle, NULL);
|
||||||
|
|
Loading…
Reference in New Issue