ws2_32/tests: Add some IPX socket tests

Bruno Jesus 00cpxxx at gmail.com
Thu Dec 26 16:11:24 CST 2013


It looks like testbot does not support IPX but I manually tested this in XP
SP3 and NT4 and the tests are OK.

These are initial tests to find the problem for bug 6941.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20131226/b05b2c9c/attachment.html>
-------------- next part --------------
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 341b7e7..4f1d357 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -26,6 +26,7 @@
 #include <windows.h>
 #include <winternl.h>
 #include <ws2tcpip.h>
+#include <wsipx.h>
 #include <mswsock.h>
 #include <mstcpip.h>
 #include <stdio.h>
@@ -2088,6 +2089,55 @@ static void test_WSASocket(void)
            SOCK_RAW, socktype);
         closesocket(sock);
     }
+
+    /* IPX socket tests */
+
+    SetLastError(0xdeadbeef);
+    sock = WSASocketA(AF_IPX, SOCK_DGRAM, NSPROTO_IPX, NULL, 0, 0);
+    if (sock == INVALID_SOCKET)
+    {
+        err = WSAGetLastError();
+        ok(err == WSAEPROTONOSUPPORT || err == WSAEAFNOSUPPORT,
+           "Expected invalid protocol (10043) or family (10047), received %d\n", err);
+        skip("IPX is not supported\n");
+    }
+    else
+    {
+        WSAPROTOCOL_INFOA info;
+        closesocket(sock);
+
+        trace("IPX is supported\n");
+
+        sock = WSASocketA(0, 0, NSPROTO_IPX, NULL, 0, 0);
+        ok(sock != INVALID_SOCKET, "Failed to create socket: %d\n",
+                WSAGetLastError());
+
+        size = sizeof(socktype);
+        socktype = 0xdead;
+        err = getsockopt(sock, SOL_SOCKET, SO_TYPE, (char *) &socktype, &size);
+        ok(!err,"getsockopt failed with %d\n", WSAGetLastError());
+        ok(socktype == SOCK_DGRAM, "Wrong socket type, expected %d received %d\n",
+           SOCK_DGRAM, socktype);
+
+        /* check socket family, type and protocol */
+        size = sizeof(WSAPROTOCOL_INFOA);
+        err = getsockopt(sock, SOL_SOCKET, SO_PROTOCOL_INFOA, (char *) &info, &size);
+        ok(!err,"getsockopt failed with %d\n", WSAGetLastError());
+        ok(info.iProtocol == NSPROTO_IPX, "expected protocol %d, received %d\n",
+           NSPROTO_IPX, info.iProtocol);
+        ok(info.iAddressFamily == AF_IPX, "expected family %d, received %d\n",
+           AF_IPX, info.iProtocol);
+        ok(info.iSocketType == SOCK_DGRAM, "expected type %d, received %d\n",
+           SOCK_DGRAM, info.iSocketType);
+        closesocket(sock);
+
+        /* SOCK_STREAM does not support NSPROTO_IPX */
+        SetLastError(0xdeadbeef);
+        ok(WSASocketA(AF_IPX, SOCK_STREAM, NSPROTO_IPX, NULL, 0, 0) == INVALID_SOCKET,
+           "WSASocketA should have failed\n");
+        err = WSAGetLastError();
+        ok(err == WSAEPROTONOSUPPORT, "Expected 10043, received %d\n", err);
+    }
 }
 
 static void test_WSADuplicateSocket(void)
@@ -2141,7 +2191,7 @@ static void test_WSADuplicateSocket(void)
        IPPROTO_TCP, info.iProtocol);
     ok(info.iAddressFamily == AF_INET, "expected family %d, received %d\n",
        AF_INET, info.iProtocol);
-    ok(info.iSocketType == SOCK_STREAM, "expected protocol %d, received %d\n",
+    ok(info.iSocketType == SOCK_STREAM, "expected type %d, received %d\n",
        SOCK_STREAM, info.iSocketType);
 
     dupsock = WSASocketA(0, 0, 0, &info, 0, 0);
@@ -2163,7 +2213,7 @@ static void test_WSADuplicateSocket(void)
        IPPROTO_UDP, info.iProtocol);
     ok(info.iAddressFamily == AF_INET, "expected family %d, received %d\n",
        AF_INET, info.iProtocol);
-    ok(info.iSocketType == SOCK_DGRAM, "expected protocol %d, received %d\n",
+    ok(info.iSocketType == SOCK_DGRAM, "expected type %d, received %d\n",
        SOCK_DGRAM, info.iSocketType);
 
     memset(&addr, 0, sizeof(addr));


More information about the wine-patches mailing list