Commit 6ccd5015 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

ws2_32/tests: Load GetHostNameW() dynamically.

It is not available on Windows 7 and lower. Signed-off-by: 's avatarFrancois Gouget <fgouget@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 2f2cdc8b
......@@ -71,6 +71,7 @@ static int (WINAPI *pGetAddrInfoExW)(const WCHAR *name, const WCHAR *servname,
struct timeval *timeout, OVERLAPPED *overlapped,
LPLOOKUPSERVICE_COMPLETION_ROUTINE completion_routine, HANDLE *handle);
static int (WINAPI *pGetAddrInfoExOverlappedResult)(OVERLAPPED *overlapped);
static int (WINAPI *pGetHostNameW)(WCHAR *, int);
static PCSTR (WINAPI *pInetNtop)(INT,LPVOID,LPSTR,ULONG);
static PCWSTR(WINAPI *pInetNtopW)(INT,LPVOID,LPWSTR,ULONG);
static int (WINAPI *pInetPtonA)(INT,LPCSTR,LPVOID);
......@@ -1203,6 +1204,7 @@ static void Init (void)
pFreeAddrInfoExW = (void *)GetProcAddress(hws2_32, "FreeAddrInfoExW");
pGetAddrInfoExW = (void *)GetProcAddress(hws2_32, "GetAddrInfoExW");
pGetAddrInfoExOverlappedResult = (void *)GetProcAddress(hws2_32, "GetAddrInfoExOverlappedResult");
pGetHostNameW = (void *)GetProcAddress(hws2_32, "GetHostNameW");
pInetNtop = (void *)GetProcAddress(hws2_32, "inet_ntop");
pInetNtopW = (void *)GetProcAddress(hws2_32, "InetNtopW");
pInetPtonA = (void *)GetProcAddress(hws2_32, "inet_pton");
......@@ -4328,26 +4330,31 @@ static void test_GetHostNameW(void)
WCHAR name[256];
int ret, len;
if (!pGetHostNameW)
{
win_skip("GetHostNameW() not present\n");
return;
}
WSASetLastError(0xdeadbeef);
ret = GetHostNameW(NULL, 256);
ret = pGetHostNameW(NULL, 256);
ok(ret == -1, "GetHostNameW() returned %d\n", ret);
ok(WSAGetLastError() == WSAEFAULT, "GetHostNameW with null buffer "
"failed with %d, expected %d\n", WSAGetLastError(), WSAEFAULT);
ret = GetHostNameW(name, sizeof(name));
ret = pGetHostNameW(name, sizeof(name));
ok(ret == 0, "GetHostNameW() call failed: %d\n", WSAGetLastError());
len = wcslen(name);
WSASetLastError(0xdeadbeef);
wcscpy(name, L"deadbeef");
ret = GetHostNameW(name, len);
ret = pGetHostNameW(name, len);
ok(ret == -1, "GetHostNameW() returned %d\n", ret);
ok(!wcscmp(name, L"deadbeef"), "name changed unexpected!\n");
ok(WSAGetLastError() == WSAEFAULT, "GetHostNameW with insufficient length "
"failed with %d, expected %d\n", WSAGetLastError(), WSAEFAULT);
len++;
ret = GetHostNameW(name, len);
ret = pGetHostNameW(name, len);
ok(ret == 0, "GetHostNameW() call failed: %d\n", WSAGetLastError());
}
......
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