diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 5a1a271b099..61af5b0183a 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -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()); }