Commit 19f4c42f authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

advapi32/tests: Fix some test failures when the computername is fully qualified.

parent 63231be8
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
static BOOL (WINAPI *pCreateWellKnownSid)(WELL_KNOWN_SID_TYPE,PSID,PSID,DWORD*); static BOOL (WINAPI *pCreateWellKnownSid)(WELL_KNOWN_SID_TYPE,PSID,PSID,DWORD*);
static BOOL (WINAPI *pGetEventLogInformation)(HANDLE,DWORD,LPVOID,DWORD,LPDWORD); static BOOL (WINAPI *pGetEventLogInformation)(HANDLE,DWORD,LPVOID,DWORD,LPDWORD);
static BOOL (WINAPI *pGetComputerNameExA)(COMPUTER_NAME_FORMAT,LPSTR,LPDWORD);
static BOOL (WINAPI *pWow64DisableWow64FsRedirection)(PVOID *); static BOOL (WINAPI *pWow64DisableWow64FsRedirection)(PVOID *);
static BOOL (WINAPI *pWow64RevertWow64FsRedirection)(PVOID); static BOOL (WINAPI *pWow64RevertWow64FsRedirection)(PVOID);
...@@ -42,6 +44,7 @@ static void init_function_pointers(void) ...@@ -42,6 +44,7 @@ static void init_function_pointers(void)
pCreateWellKnownSid = (void*)GetProcAddress(hadvapi32, "CreateWellKnownSid"); pCreateWellKnownSid = (void*)GetProcAddress(hadvapi32, "CreateWellKnownSid");
pGetEventLogInformation = (void*)GetProcAddress(hadvapi32, "GetEventLogInformation"); pGetEventLogInformation = (void*)GetProcAddress(hadvapi32, "GetEventLogInformation");
pGetComputerNameExA = (void*)GetProcAddress(hkernel32, "GetComputerNameExA");
pWow64DisableWow64FsRedirection = (void*)GetProcAddress(hkernel32, "Wow64DisableWow64FsRedirection"); pWow64DisableWow64FsRedirection = (void*)GetProcAddress(hkernel32, "Wow64DisableWow64FsRedirection");
pWow64RevertWow64FsRedirection = (void*)GetProcAddress(hkernel32, "Wow64RevertWow64FsRedirection"); pWow64RevertWow64FsRedirection = (void*)GetProcAddress(hkernel32, "Wow64RevertWow64FsRedirection");
} }
...@@ -709,8 +712,8 @@ static void test_readwrite(void) ...@@ -709,8 +712,8 @@ static void test_readwrite(void)
BOOL ret, sidavailable; BOOL ret, sidavailable;
BOOL on_vista = FALSE; /* Used to indicate Vista, W2K8 or Win7 */ BOOL on_vista = FALSE; /* Used to indicate Vista, W2K8 or Win7 */
int i; int i;
char localcomputer[MAX_COMPUTERNAME_LENGTH + 1]; char *localcomputer;
DWORD len = sizeof(localcomputer); DWORD size;
if (pCreateWellKnownSid) if (pCreateWellKnownSid)
{ {
...@@ -727,7 +730,23 @@ static void test_readwrite(void) ...@@ -727,7 +730,23 @@ static void test_readwrite(void)
user = NULL; user = NULL;
} }
GetComputerNameA(localcomputer, &len); if (pGetComputerNameExA)
{
size = 0;
SetLastError(0xdeadbeef);
pGetComputerNameExA(ComputerNameDnsFullyQualified, NULL, &size);
/* Cope with W2K (needed size is not set) */
if (size == 0 && GetLastError() == ERROR_MORE_DATA)
size = 1024;
localcomputer = HeapAlloc(GetProcessHeap(), 0, size);
pGetComputerNameExA(ComputerNameDnsFullyQualified, localcomputer, &size);
}
else
{
size = MAX_COMPUTERNAME_LENGTH + 1;
localcomputer = HeapAlloc(GetProcessHeap(), 0, size);
GetComputerNameA(localcomputer, &size);
}
/* Write an event with an incorrect event type. This will fail on Windows 7 /* Write an event with an incorrect event type. This will fail on Windows 7
* but succeed on all others, hence it's not part of the struct. * but succeed on all others, hence it's not part of the struct.
...@@ -737,8 +756,7 @@ static void test_readwrite(void) ...@@ -737,8 +756,7 @@ static void test_readwrite(void)
{ {
/* Intermittently seen on NT4 when tests are run immediately after boot */ /* Intermittently seen on NT4 when tests are run immediately after boot */
win_skip("Could not get a handle to the eventlog\n"); win_skip("Could not get a handle to the eventlog\n");
HeapFree(GetProcessHeap(), 0, user); goto cleanup;
return;
} }
count = 0xdeadbeef; count = 0xdeadbeef;
...@@ -756,9 +774,8 @@ static void test_readwrite(void) ...@@ -756,9 +774,8 @@ static void test_readwrite(void)
if (count != 0) if (count != 0)
{ {
win_skip("We didn't open our new eventlog\n"); win_skip("We didn't open our new eventlog\n");
HeapFree(GetProcessHeap(), 0, user);
CloseEventLog(handle); CloseEventLog(handle);
return; goto cleanup;
} }
} }
...@@ -854,7 +871,7 @@ static void test_readwrite(void) ...@@ -854,7 +871,7 @@ static void test_readwrite(void)
if (count == 0) if (count == 0)
{ {
skip("No events were written to the eventlog\n"); skip("No events were written to the eventlog\n");
return; goto cleanup;
} }
/* Report only once */ /* Report only once */
...@@ -962,8 +979,6 @@ static void test_readwrite(void) ...@@ -962,8 +979,6 @@ static void test_readwrite(void)
} }
CloseEventLog(handle); CloseEventLog(handle);
HeapFree(GetProcessHeap(), 0, user);
/* Test clearing a real eventlog */ /* Test clearing a real eventlog */
handle = OpenEventLogA(NULL, eventlogname); handle = OpenEventLogA(NULL, eventlogname);
...@@ -977,6 +992,10 @@ static void test_readwrite(void) ...@@ -977,6 +992,10 @@ static void test_readwrite(void)
ok(count == 0, "Expected an empty eventlog, got %d records\n", count); ok(count == 0, "Expected an empty eventlog, got %d records\n", count);
CloseEventLog(handle); CloseEventLog(handle);
cleanup:
HeapFree(GetProcessHeap(), 0, localcomputer);
HeapFree(GetProcessHeap(), 0, user);
} }
/* Before Vista: /* Before Vista:
......
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