Francois Gouget : ws2_32/tests: Skip some raw socket tests when missing elevated privileges.

Alexandre Julliard julliard at winehq.org
Mon Dec 14 15:51:17 CST 2020


Module: wine
Branch: master
Commit: 948e08152bbe12c511526e2515bd11b5da4e78fa
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=948e08152bbe12c511526e2515bd11b5da4e78fa

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Mon Dec 14 15:45:46 2020 +0100

ws2_32/tests: Skip some raw socket tests when missing elevated privileges.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ws2_32/tests/sock.c | 46 ++++++++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 20 deletions(-)

diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 2d69a05aec5..8711b65fcea 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -2551,29 +2551,35 @@ static void test_WSASocket(void)
            SOCK_RAW, socktype);
         closesocket(sock);
 
-        todo_wine {
         sock = WSASocketA(0, 0, IPPROTO_RAW, 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_RAW, "Wrong socket type, expected %d received %d\n",
-           SOCK_RAW, socktype);
-        closesocket(sock);
+        if (sock != INVALID_SOCKET)
+        {
+            todo_wine {
+            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_RAW, "Wrong socket type, expected %d received %d\n",
+               SOCK_RAW, socktype);
+            closesocket(sock);
+            }
+
+            sock = WSASocketA(AF_INET, SOCK_RAW, IPPROTO_TCP, 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_RAW, "Wrong socket type, expected %d received %d\n",
+               SOCK_RAW, socktype);
+            closesocket(sock);
         }
+        else if (WSAGetLastError() == WSAEACCES)
+            skip("SOCK_RAW is not available\n");
+        else
+            ok(0, "Failed to create socket: %d\n", WSAGetLastError());
 
-        sock = WSASocketA(AF_INET, SOCK_RAW, IPPROTO_TCP, 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_RAW, "Wrong socket type, expected %d received %d\n",
-           SOCK_RAW, socktype);
-        closesocket(sock);
     }
 
     /* IPX socket tests */




More information about the wine-cvs mailing list