[PATCH v3 1/2] ws2_32/tests: Check if getsockopt returns non-zero protocol for sockets with autoselected protocol

Robin Ebert ebertrobin2002 at gmail.com
Mon Aug 24 12:14:41 CDT 2020


Signed-off-by: Robin Ebert <ebertrobin2002 at gmail.com>
---
v3: Fixed commit message
---
 dlls/ws2_32/tests/sock.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index b523c326..1450038f 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -1750,6 +1750,21 @@ todo_wine
         closesocket(s);
     }
 
+    /* when no protocol is specified
+     * and the socket creation doesn't fail
+     * the socket should have a valid WSAPROTOCOL_INFOW struct */
+    s = WSASocketW(AF_INET, SOCK_STREAM, 0, NULL, 0, 0);
+    ok(s != INVALID_SOCKET, "Failed to create socket: %d\n",
+            WSAGetLastError());
+
+    size = sizeof(WSAPROTOCOL_INFOW);
+    err = getsockopt(s, SOL_SOCKET, SO_PROTOCOL_INFOW, (char *)&infoW, &size);
+
+    ok(!err, "getsockopt failed with %d\n", WSAGetLastError());
+    if(!err)
+        ok(infoW.iProtocol != 0, "getsockopt returned zero protocol\n");
+    closesocket(s);
+
     /* Test SO_BSP_STATE - Present only in >= Win 2008 */
     s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
     ok(s != INVALID_SOCKET, "Failed to create socket\n");
-- 
2.20.1




More information about the wine-devel mailing list