Author: akhaldi
Date: Sun Sep 24 11:36:21 2017
New Revision: 75960
URL:
http://svn.reactos.org/svn/reactos?rev=75960&view=rev
Log:
[WS2_32_WINETEST] Sync with Wine Staging 2.16. CORE-13762
Modified:
trunk/rostests/winetests/ws2_32/sock.c
Modified: trunk/rostests/winetests/ws2_32/sock.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/ws2_32/sock.c?r…
==============================================================================
--- trunk/rostests/winetests/ws2_32/sock.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/ws2_32/sock.c [iso-8859-1] Sun Sep 24 11:36:21 2017
@@ -72,7 +72,13 @@
static void (WINAPI *pfreeaddrinfo)(struct addrinfo *);
static int (WINAPI *pgetaddrinfo)(LPCSTR,LPCSTR,const struct addrinfo *,struct addrinfo
**);
static void (WINAPI *pFreeAddrInfoW)(PADDRINFOW);
+static void (WINAPI *pFreeAddrInfoExW)(ADDRINFOEXW *ai);
static int (WINAPI *pGetAddrInfoW)(LPCWSTR,LPCWSTR,const ADDRINFOW *,PADDRINFOW *);
+static int (WINAPI *pGetAddrInfoExW)(const WCHAR *name, const WCHAR *servname, DWORD
namespace,
+ GUID *namespace_id, const ADDRINFOEXW *hints, ADDRINFOEXW **result,
+ struct timeval *timeout, OVERLAPPED *overlapped,
+ LPLOOKUPSERVICE_COMPLETION_ROUTINE completion_routine, HANDLE *handle);
+static int (WINAPI *pGetAddrInfoExOverlappedResult)(OVERLAPPED *overlapped);
static PCSTR (WINAPI *pInetNtop)(INT,LPVOID,LPSTR,ULONG);
static PCWSTR(WINAPI *pInetNtopW)(INT,LPVOID,LPWSTR,ULONG);
static int (WINAPI *pInetPtonA)(INT,LPCSTR,LPVOID);
@@ -1234,7 +1240,10 @@
pfreeaddrinfo = (void *)GetProcAddress(hws2_32, "freeaddrinfo");
pgetaddrinfo = (void *)GetProcAddress(hws2_32, "getaddrinfo");
pFreeAddrInfoW = (void *)GetProcAddress(hws2_32, "FreeAddrInfoW");
+ pFreeAddrInfoExW = (void *)GetProcAddress(hws2_32, "FreeAddrInfoExW");
pGetAddrInfoW = (void *)GetProcAddress(hws2_32, "GetAddrInfoW");
+ pGetAddrInfoExW = (void *)GetProcAddress(hws2_32, "GetAddrInfoExW");
+ pGetAddrInfoExOverlappedResult = (void *)GetProcAddress(hws2_32,
"GetAddrInfoExOverlappedResult");
pInetNtop = (void *)GetProcAddress(hws2_32, "inet_ntop");
pInetNtopW = (void *)GetProcAddress(hws2_32, "InetNtopW");
pInetPtonA = (void *)GetProcAddress(hws2_32, "inet_pton");
@@ -1654,7 +1663,7 @@
ok(k == 99, "Expected 99, got %d\n", k);
}
}
- else /* <= 2003 the tests differ between TCP and UDP, UDP silenty accepts */
+ else /* <= 2003 the tests differ between TCP and UDP, UDP silently accepts */
{
SetLastError(0xdeadbeef);
k = 99;
@@ -3613,6 +3622,7 @@
struct sockaddr_in addr;
struct timeval select_timeout;
+ memset(&readfds, 0, sizeof(readfds));
FD_ZERO(&readfds);
FD_SET(par->s, &readfds);
select_timeout.tv_sec=5;
@@ -4785,7 +4795,7 @@
}
ok(memcmp(he->h_addr_list[0], loopback, he->h_length) == 0,
- "gethostbyname(\"localhost\") returned %d.%d.%d.%d\n",
+ "gethostbyname(\"localhost\") returned %u.%u.%u.%u\n",
he->h_addr_list[0][0], he->h_addr_list[0][1], he->h_addr_list[0][2],
he->h_addr_list[0][3]);
}
@@ -4809,7 +4819,7 @@
if (he->h_addr_list[0][0] == 127)
{
ok(memcmp(he->h_addr_list[0], magic_loopback, he->h_length) == 0,
- "gethostbyname(\"%s\") returned %d.%d.%d.%d not
127.12.34.56\n",
+ "gethostbyname(\"%s\") returned %u.%u.%u.%u not
127.12.34.56\n",
name, he->h_addr_list[0][0], he->h_addr_list[0][1],
he->h_addr_list[0][2], he->h_addr_list[0][3]);
}
@@ -6871,7 +6881,6 @@
memset(&ov, 0, sizeof(ov));
completion_called = 0;
iret = WSARecv(dest, bufs, 1, NULL, &flags, &ov, io_completion);
- todo_wine
ok(iret == SOCKET_ERROR && GetLastError() == WSAEINVAL, "WSARecv failed
- %d error %d\n", iret, GetLastError());
ok(!completion_called, "completion called\n");
@@ -7382,11 +7391,124 @@
ok(result2 == NULL, "got %p\n", result2);
}
+static void test_GetAddrInfoExW(void)
+{
+ static const WCHAR empty[] = {0};
+ static const WCHAR localhost[] =
{'l','o','c','a','l','h','o','s','t',0};
+ static const WCHAR winehq[] =
{'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0};
+ ADDRINFOEXW *result;
+ OVERLAPPED overlapped;
+ HANDLE event;
+ int ret;
+
+ if (!pGetAddrInfoExW || !pGetAddrInfoExOverlappedResult)
+ {
+ win_skip("GetAddrInfoExW and/or GetAddrInfoExOverlappedResult not
present\n");
+ return;
+ }
+
+ event = WSACreateEvent();
+
+ result = (ADDRINFOEXW *)0xdeadbeef;
+ WSASetLastError(0xdeadbeef);
+ ret = pGetAddrInfoExW(NULL, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL,
NULL);
+ ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
+ ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n",
WSAGetLastError());
+ ok(result == NULL, "got %p\n", result);
+
+ result = NULL;
+ WSASetLastError(0xdeadbeef);
+ ret = pGetAddrInfoExW(empty, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL, NULL,
NULL);
+ ok(!ret, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ ok(result != NULL, "GetAddrInfoW failed\n");
+ ok(WSAGetLastError() == 0, "expected 0, got %d\n", WSAGetLastError());
+ pFreeAddrInfoExW(result);
+
+ result = NULL;
+ ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL, NULL,
NULL, NULL);
+ ok(!ret, "GetAddrInfoExW failed with %d\n", WSAGetLastError());
+ pFreeAddrInfoExW(result);
+
+ result = (void*)0xdeadbeef;
+ memset(&overlapped, 0xcc, sizeof(overlapped));
+ overlapped.hEvent = event;
+ ResetEvent(event);
+ ret = pGetAddrInfoExW(localhost, NULL, NS_DNS, NULL, NULL, &result, NULL,
&overlapped, NULL, NULL);
+ ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n",
WSAGetLastError());
+ ok(!result, "result != NULL\n");
+ ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
+ ret = pGetAddrInfoExOverlappedResult(&overlapped);
+ ok(!ret, "overlapped result is %d\n", ret);
+ pFreeAddrInfoExW(result);
+
+ result = (void*)0xdeadbeef;
+ memset(&overlapped, 0xcc, sizeof(overlapped));
+ ResetEvent(event);
+ overlapped.hEvent = event;
+ WSASetLastError(0xdeadbeef);
+ ret = pGetAddrInfoExW(winehq, NULL, NS_DNS, NULL, NULL, &result, NULL,
&overlapped, NULL, NULL);
+ ok(ret == ERROR_IO_PENDING, "GetAddrInfoExW failed with %d\n",
WSAGetLastError());
+ ok(WSAGetLastError() == ERROR_IO_PENDING, "expected 11001, got %d\n",
WSAGetLastError());
+ ret = overlapped.Internal;
+ ok(ret == WSAEINPROGRESS || ret == ERROR_SUCCESS, "overlapped.Internal =
%u\n", ret);
+ ok(WaitForSingleObject(event, 1000) == WAIT_OBJECT_0, "wait failed\n");
+ ret = pGetAddrInfoExOverlappedResult(&overlapped);
+ ok(!ret, "overlapped result is %d\n", ret);
+ ok(overlapped.hEvent == event, "hEvent changed %p\n", overlapped.hEvent);
+ ok(overlapped.Internal == ERROR_SUCCESS, "overlapped.Internal = %lx\n",
overlapped.Internal);
+ ok(overlapped.Pointer == &result, "overlapped.Pointer !=
&result\n");
+ ok(result != NULL, "result == NULL\n");
+ ok(!result->ai_blob, "ai_blob != NULL\n");
+ ok(!result->ai_bloblen, "ai_bloblen != 0\n");
+ ok(!result->ai_provider, "ai_provider = %s\n",
wine_dbgstr_guid(result->ai_provider));
+ pFreeAddrInfoExW(result);
+
+ result = (void*)0xdeadbeef;
+ memset(&overlapped, 0xcc, sizeof(overlapped));
+ ResetEvent(event);
+ overlapped.hEvent = event;
+ ret = pGetAddrInfoExW(NULL, NULL, NS_DNS, NULL, NULL, &result, NULL,
&overlapped, NULL, NULL);
+ todo_wine
+ ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
+ todo_wine
+ ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n",
WSAGetLastError());
+ ok(result == NULL, "got %p\n", result);
+ ret = WaitForSingleObject(event, 0);
+ todo_wine_if(ret != WAIT_TIMEOUT) /* Remove when abowe todo_wines are fixed */
+ ok(ret == WAIT_TIMEOUT, "wait failed\n");
+
+ WSACloseEvent(event);
+}
+
+static void verify_ipv6_addrinfo(ADDRINFOA *result, const char *expectedIp)
+{
+ SOCKADDR_IN6 *sockaddr6;
+ char ipBuffer[256];
+ const char *ret;
+
+ ok(result->ai_family == AF_INET6, "ai_family == %d\n",
result->ai_family);
+ ok(result->ai_addrlen >= sizeof(struct sockaddr_in6), "ai_addrlen ==
%d\n", (int)result->ai_addrlen);
+ ok(result->ai_addr != NULL, "ai_addr == NULL\n");
+
+ if (result->ai_addr != NULL)
+ {
+ sockaddr6 = (SOCKADDR_IN6 *)result->ai_addr;
+ ok(sockaddr6->sin6_family == AF_INET6, "ai_addr->sin6_family ==
%d\n", sockaddr6->sin6_family);
+ ok(sockaddr6->sin6_port == 0, "ai_addr->sin6_port == %d\n",
sockaddr6->sin6_port);
+
+ ZeroMemory(ipBuffer, sizeof(ipBuffer));
+ ret = pInetNtop(AF_INET6, &sockaddr6->sin6_addr, ipBuffer,
sizeof(ipBuffer));
+ ok(ret != NULL, "inet_ntop failed (%d)\n", WSAGetLastError());
+ ok(strcmp(ipBuffer, expectedIp) == 0, "ai_addr->sin6_addr == '%s'
(expected '%s')\n", ipBuffer, expectedIp);
+ }
+}
+
static void test_getaddrinfo(void)
{
int i, ret;
ADDRINFOA *result, *result2, *p, hint;
- CHAR name[256];
+ SOCKADDR_IN *sockaddr;
+ CHAR name[256], *ip;
DWORD size = sizeof(name);
if (!pgetaddrinfo || !pfreeaddrinfo)
@@ -7515,6 +7637,88 @@
ok(ret == WSAHOST_NOT_FOUND, "got %d expected WSAHOST_NOT_FOUND\n", ret);
ok(WSAGetLastError() == WSAHOST_NOT_FOUND, "expected 11001, got %d\n",
WSAGetLastError());
ok(result == NULL, "got %p\n", result);
+
+ /* Test IPv4 address conversion */
+ result = NULL;
+ ret = pgetaddrinfo("192.168.1.253", NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ ok(result->ai_family == AF_INET, "ai_family == %d\n",
result->ai_family);
+ ok(result->ai_addrlen >= sizeof(struct sockaddr_in), "ai_addrlen ==
%d\n", (int)result->ai_addrlen);
+ ok(result->ai_addr != NULL, "ai_addr == NULL\n");
+ sockaddr = (SOCKADDR_IN *)result->ai_addr;
+ ok(sockaddr->sin_family == AF_INET, "ai_addr->sin_family == %d\n",
sockaddr->sin_family);
+ ok(sockaddr->sin_port == 0, "ai_addr->sin_port == %d\n",
sockaddr->sin_port);
+
+ ip = inet_ntoa(sockaddr->sin_addr);
+ ok(strcmp(ip, "192.168.1.253") == 0, "sockaddr->ai_addr ==
'%s'\n", ip);
+ pfreeaddrinfo(result);
+
+ /* Test IPv4 address conversion with port */
+ result = NULL;
+ hint.ai_flags = AI_NUMERICHOST;
+ ret = pgetaddrinfo("192.168.1.253:1024", NULL, &hint, &result);
+ hint.ai_flags = 0;
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo returned unexpected result:
%d\n", ret);
+ ok(result == NULL, "expected NULL, got %p\n", result);
+
+ /* Test IPv6 address conversion */
+ result = NULL;
+ SetLastError(0xdeadbeef);
+ ret = pgetaddrinfo("2a00:2039:dead:beef:cafe::6666", NULL, NULL,
&result);
+
+ if (result != NULL)
+ {
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ verify_ipv6_addrinfo(result, "2a00:2039:dead:beef:cafe::6666");
+ pfreeaddrinfo(result);
+
+ /* Test IPv6 address conversion with brackets */
+ result = NULL;
+ ret = pgetaddrinfo("[beef::cafe]", NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ verify_ipv6_addrinfo(result, "beef::cafe");
+ pfreeaddrinfo(result);
+
+ /* Test IPv6 address conversion with brackets and hints */
+ memset(&hint, 0, sizeof(ADDRINFOA));
+ hint.ai_flags = AI_NUMERICHOST;
+ hint.ai_family = AF_INET6;
+ result = NULL;
+ ret = pgetaddrinfo("[beef::cafe]", NULL, &hint, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ verify_ipv6_addrinfo(result, "beef::cafe");
+ pfreeaddrinfo(result);
+
+ memset(&hint, 0, sizeof(ADDRINFOA));
+ hint.ai_flags = AI_NUMERICHOST;
+ hint.ai_family = AF_INET;
+ result = NULL;
+ ret = pgetaddrinfo("[beef::cafe]", NULL, &hint, &result);
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
+
+ /* Test IPv6 address conversion with brackets and port */
+ result = NULL;
+ ret = pgetaddrinfo("[beef::cafe]:10239", NULL, NULL, &result);
+ ok(!ret, "getaddrinfo failed with %d\n", ret);
+ verify_ipv6_addrinfo(result, "beef::cafe");
+ pfreeaddrinfo(result);
+
+ /* Test IPv6 address conversion with unmatched brackets */
+ result = NULL;
+ hint.ai_flags = AI_NUMERICHOST;
+ ret = pgetaddrinfo("[beef::cafe", NULL, &hint, &result);
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
+
+ ret = pgetaddrinfo("beef::cafe]", NULL, &hint, &result);
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
+ }
+ else
+ {
+ ok(ret == WSAHOST_NOT_FOUND, "getaddrinfo failed with %d\n", ret);
+ win_skip("getaddrinfo does not support IPV6\n");
+ }
+
+ hint.ai_flags = 0;
for (i = 0;i < (sizeof(hinttests) / sizeof(hinttests[0]));i++)
{
@@ -7619,12 +7823,15 @@
goto end;
}
+ bytesReturned = 0xdeadbeef;
iret = WSAIoctl(connector, SIO_GET_EXTENSION_FUNCTION_POINTER, &connectExGuid,
sizeof(connectExGuid),
&pConnectEx, sizeof(pConnectEx), &bytesReturned, NULL, NULL);
if (iret) {
win_skip("WSAIoctl failed to get ConnectEx with ret %d + errno %d\n",
iret, WSAGetLastError());
goto end;
}
+
+ ok(bytesReturned == sizeof(pConnectEx), "expected sizeof(pConnectEx), got
%u\n", bytesReturned);
bret = pConnectEx(INVALID_SOCKET, (struct sockaddr*)&address, addrlen, NULL, 0,
&bytesReturned, &overlapped);
ok(bret == FALSE && WSAGetLastError() == WSAENOTSOCK, "ConnectEx on
invalid socket "
@@ -7756,22 +7963,14 @@
address.sin_port = htons(1);
bret = pConnectEx(connector, (struct sockaddr*)&address, addrlen, NULL, 0,
&bytesReturned, &overlapped);
- ok(bret == FALSE && GetLastError(), "ConnectEx to bad destination
failed: "
+ ok(bret == FALSE && GetLastError() == ERROR_IO_PENDING, "ConnectEx to
bad destination failed: "
"returned %d + errno %d\n", bret, GetLastError());
-
- if (GetLastError() == ERROR_IO_PENDING)
- {
- dwret = WaitForSingleObject(overlapped.hEvent, 15000);
- ok(dwret == WAIT_OBJECT_0, "Waiting for connect event failed with %d + errno
%d\n", dwret, GetLastError());
-
- bret = GetOverlappedResult((HANDLE)connector, &overlapped,
&bytesReturned, FALSE);
- ok(bret == FALSE && GetLastError() == ERROR_CONNECTION_REFUSED,
- "Connecting to a disconnected host returned error %d - %d\n", bret,
WSAGetLastError());
- }
- else {
- ok(GetLastError() == WSAECONNREFUSED,
- "Connecting to a disconnected host returned error %d - %d\n", bret,
WSAGetLastError());
- }
+ dwret = WaitForSingleObject(overlapped.hEvent, 15000);
+ ok(dwret == WAIT_OBJECT_0, "Waiting for connect event failed with %d + errno
%d\n", dwret, GetLastError());
+
+ bret = GetOverlappedResult((HANDLE)connector, &overlapped, &bytesReturned,
FALSE);
+ ok(bret == FALSE && GetLastError() == ERROR_CONNECTION_REFUSED,
+ "Connecting to a disconnected host returned error %d - %d\n", bret,
WSAGetLastError());
end:
if (overlapped.hEvent)
@@ -9852,6 +10051,11 @@
io_port = CreateIoCompletionPort((HANDLE)dest, previous_port, 236, 0);
ok(io_port != NULL, "failed to create completion port %u\n",
GetLastError());
+
+ io_info.Flags = FILE_SKIP_COMPLETION_PORT_ON_SUCCESS;
+ status = pNtSetInformationFile((HANDLE)src, &io, &io_info, sizeof(io_info),
FileIoCompletionNotificationInformation);
+ ok(status == STATUS_SUCCESS || broken(status == STATUS_INVALID_INFO_CLASS) /* XP */,
+ "expected STATUS_SUCCESS, got %08x\n", status);
io_info.Flags = FILE_SKIP_COMPLETION_PORT_ON_SUCCESS;
status = pNtSetInformationFile((HANDLE)dest, &io, &io_info, sizeof(io_info),
FileIoCompletionNotificationInformation);
@@ -10559,6 +10763,7 @@
test_ipv6only();
test_TransmitFile();
test_GetAddrInfoW();
+ test_GetAddrInfoExW();
test_getaddrinfo();
test_AcceptEx();
test_ConnectEx();