From 72c54e5d3b5bb8c1a66eee9291597fd49750993f Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Tue, 8 Dec 2009 09:28:49 +0100 Subject: [PATCH] adapi32/tests: Fix test failures when the computername is fully qualified on W2K3 and earlier. --- dlls/advapi32/tests/eventlog.c | 36 ++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/dlls/advapi32/tests/eventlog.c b/dlls/advapi32/tests/eventlog.c index a781c0613c7..c0f516acd6f 100644 --- a/dlls/advapi32/tests/eventlog.c +++ b/dlls/advapi32/tests/eventlog.c @@ -712,7 +712,7 @@ static void test_readwrite(void) BOOL ret, sidavailable; BOOL on_vista = FALSE; /* Used to indicate Vista, W2K8 or Win7 */ int i; - char *localcomputer; + char *localcomputer = NULL; DWORD size; if (pCreateWellKnownSid) @@ -730,24 +730,6 @@ static void test_readwrite(void) user = NULL; } - 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 * but succeed on all others, hence it's not part of the struct. */ @@ -878,6 +860,22 @@ static void test_readwrite(void) if (on_vista) skip("There is no DWORD alignment enforced for UserSid on Vista, W2K8 or Win7\n"); + if (on_vista && pGetComputerNameExA) + { + /* New Vista+ behavior */ + size = 0; + SetLastError(0xdeadbeef); + pGetComputerNameExA(ComputerNameDnsFullyQualified, NULL, &size); + localcomputer = HeapAlloc(GetProcessHeap(), 0, size); + pGetComputerNameExA(ComputerNameDnsFullyQualified, localcomputer, &size); + } + else + { + size = MAX_COMPUTERNAME_LENGTH + 1; + localcomputer = HeapAlloc(GetProcessHeap(), 0, size); + GetComputerNameA(localcomputer, &size); + } + /* Read all events from our created eventlog, one by one */ handle = OpenEventLogA(NULL, eventlogname); i = 0;