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