This test replicates what Microsoft-MPI (https://github.com/microsoft/Microsoft-MPI/tree/master/src) and its backend NetworkDirect (https://github.com/microsoft/NetworkDirect/blob/master/src/ndutil/ndfrmwrk.c...) depend on.
-- v2: ws2_32: Return a socket from WSAProviderConfigChange() stub. ws2_32/tests: Add a simple test for WSAProviderConfigChange().
From: Dmitry Timoshkov dmitry@baikal.ru
This test replicates what Microsoft-MPI and its backend NetworkDirect (ND) depend on.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/ws2_32/tests/protocol.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
diff --git a/dlls/ws2_32/tests/protocol.c b/dlls/ws2_32/tests/protocol.c index bad3e6648b5..5826f161e01 100644 --- a/dlls/ws2_32/tests/protocol.c +++ b/dlls/ws2_32/tests/protocol.c @@ -3135,6 +3135,36 @@ static void test_startup(void) } }
+static void test_WSAProviderConfigChange(void) +{ + SOCKET sock; + OVERLAPPED ov = { 0 }; + int ret; + HANDLE port, port2, change; + DWORD bytes; + + change = 0; + ret = WSAProviderConfigChange(&change, NULL, NULL); + todo_wine + ok(ret != SOCKET_ERROR, "WSAProviderConfigChange() error %u\n", WSAGetLastError()); + + port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0); + ok(!!port, "CreateIoCompletionPort() error %lu\n", GetLastError()); + sock = WSASocketW(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED); + ok(sock != SOCKET_ERROR, "WSASocketW() error %u\n", WSAGetLastError()); + port2 = CreateIoCompletionPort((HANDLE)sock, port, 123, 0); + ok(port2 == port, "got %p/%p\n", port, port2); + port2 = CreateIoCompletionPort(change, port, 456, 0); + todo_wine + ok(port2 == port, "got %p/%p\n", port, port2); + ret = WSAIoctl(sock, SIO_ADDRESS_LIST_CHANGE, NULL, 0, NULL, 0, &bytes, &ov, NULL); + ok(ret, "WSAIoctl() error %u\n", WSAGetLastError()); + + closesocket(sock); + CloseHandle(port); + CloseHandle(change); +} + START_TEST( protocol ) { WSADATA data; @@ -3184,6 +3214,7 @@ START_TEST( protocol ) test_WSCGetApplicationCategory(); test_WSCGetProviderInfo(); test_WSCGetProviderPath(); + test_WSAProviderConfigChange();
WSACleanup();
From: Dmitry Timoshkov dmitry@baikal.ru
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/ws2_32/protocol.c | 20 +++++++++++++++++++- dlls/ws2_32/tests/protocol.c | 2 -- 2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/dlls/ws2_32/protocol.c b/dlls/ws2_32/protocol.c index 2699593a2f3..c0add6b5dc4 100644 --- a/dlls/ws2_32/protocol.c +++ b/dlls/ws2_32/protocol.c @@ -2174,8 +2174,26 @@ int WINAPI WSAEnumNameSpaceProvidersW( DWORD *len, WSANAMESPACE_INFOW *buffer ) int WINAPI WSAProviderConfigChange( HANDLE *handle, OVERLAPPED *overlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE completion ) { + SOCKET s; + FIXME( "(%p %p %p) Stub!\n", handle, overlapped, completion ); - return -1; + + if (!handle) + { + SetLastError( WSAEFAULT ); + return SOCKET_ERROR; + } + + if (*handle != NULL) return 0; + + s = WSASocketW( AF_INET, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED ); + if (s != INVALID_SOCKET) + { + *handle = (HANDLE)s; + return 0; + } + + return SOCKET_ERROR; }
diff --git a/dlls/ws2_32/tests/protocol.c b/dlls/ws2_32/tests/protocol.c index 5826f161e01..5da1bd3eae4 100644 --- a/dlls/ws2_32/tests/protocol.c +++ b/dlls/ws2_32/tests/protocol.c @@ -3145,7 +3145,6 @@ static void test_WSAProviderConfigChange(void)
change = 0; ret = WSAProviderConfigChange(&change, NULL, NULL); - todo_wine ok(ret != SOCKET_ERROR, "WSAProviderConfigChange() error %u\n", WSAGetLastError());
port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0); @@ -3155,7 +3154,6 @@ static void test_WSAProviderConfigChange(void) port2 = CreateIoCompletionPort((HANDLE)sock, port, 123, 0); ok(port2 == port, "got %p/%p\n", port, port2); port2 = CreateIoCompletionPort(change, port, 456, 0); - todo_wine ok(port2 == port, "got %p/%p\n", port, port2); ret = WSAIoctl(sock, SIO_ADDRESS_LIST_CHANGE, NULL, 0, NULL, 0, &bytes, &ov, NULL); ok(ret, "WSAIoctl() error %u\n", WSAGetLastError());
v2: Fix a test failure.
So, I looked back to see if I have a patch for this and did not see one. I'm assuming a related patch is why I was requested for a review. That said, taking a look at this I was a little confused by:
if (*handle != NULL) return 0;
at first. I'm not sure how I would do it better though, especially since this is still stub behavior, so I'll call it good :smile:
This merge request was approved by Erich Hoover.