advapi32/tests: Fix the ReadEventLog error checking.
This commit is contained in:
parent
2ef6101768
commit
71fa5a36b1
|
@ -767,22 +767,28 @@ static void test_readwrite(void)
|
||||||
{
|
{
|
||||||
win_skip("Win7 fails when using incorrect event types\n");
|
win_skip("Win7 fails when using incorrect event types\n");
|
||||||
ret = ReportEvent(handle, 0, 0, 0, NULL, 0, 0, NULL, NULL);
|
ret = ReportEvent(handle, 0, 0, 0, NULL, 0, 0, NULL, NULL);
|
||||||
|
ok(ret, "Expected success : %d\n", GetLastError());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
void *buf;
|
void *buf;
|
||||||
DWORD read, needed;
|
DWORD read, needed = 0;
|
||||||
EVENTLOGRECORD *record;
|
EVENTLOGRECORD *record;
|
||||||
|
|
||||||
|
ok(ret, "Expected success : %d\n", GetLastError());
|
||||||
|
|
||||||
/* Needed to catch earlier Vista (with no ServicePack for example) */
|
/* Needed to catch earlier Vista (with no ServicePack for example) */
|
||||||
buf = HeapAlloc(GetProcessHeap(), 0, sizeof(EVENTLOGRECORD));
|
buf = HeapAlloc(GetProcessHeap(), 0, sizeof(EVENTLOGRECORD));
|
||||||
if (ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
|
if (!(ret = ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
|
||||||
0, buf, sizeof(EVENTLOGRECORD), &read, &needed))
|
0, buf, sizeof(EVENTLOGRECORD), &read, &needed)) &&
|
||||||
|
GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||||
{
|
{
|
||||||
buf = HeapReAlloc(GetProcessHeap(), 0, buf, needed);
|
buf = HeapReAlloc(GetProcessHeap(), 0, buf, needed);
|
||||||
ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
|
ret = ReadEventLogA(handle, EVENTLOG_SEQUENTIAL_READ | EVENTLOG_FORWARDS_READ,
|
||||||
0, buf, needed, &read, &needed);
|
0, buf, needed, &read, &needed);
|
||||||
|
}
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
record = (EVENTLOGRECORD *)buf;
|
record = (EVENTLOGRECORD *)buf;
|
||||||
|
|
||||||
/* Vista and W2K8 return EVENTLOG_SUCCESS, Windows versions before return
|
/* Vista and W2K8 return EVENTLOG_SUCCESS, Windows versions before return
|
||||||
|
@ -793,7 +799,6 @@ static void test_readwrite(void)
|
||||||
}
|
}
|
||||||
HeapFree(GetProcessHeap(), 0, buf);
|
HeapFree(GetProcessHeap(), 0, buf);
|
||||||
}
|
}
|
||||||
ok(ret, "Expected success : %d\n", GetLastError());
|
|
||||||
|
|
||||||
/* This will clear the eventlog. The record numbering for new
|
/* This will clear the eventlog. The record numbering for new
|
||||||
* events however differs on Vista SP1+. Before Vista the first
|
* events however differs on Vista SP1+. Before Vista the first
|
||||||
|
|
Loading…
Reference in New Issue