[PATCH 1/5] ws2_32/tests: Fix some connection timeout tests.

Zebediah Figura zfigura at codeweavers.com
Mon Jul 5 19:14:15 CDT 2021


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/ws2_32/tests/afd.c  |  6 ++++--
 dlls/ws2_32/tests/sock.c | 30 ++++++++++++++++++++++--------
 2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/dlls/ws2_32/tests/afd.c b/dlls/ws2_32/tests/afd.c
index 8f7f4acf4f2..2637630ce8d 100644
--- a/dlls/ws2_32/tests/afd.c
+++ b/dlls/ws2_32/tests/afd.c
@@ -448,7 +448,8 @@ static void test_poll(void)
 
         addr.sin_port = 255;
         ret = connect(client, (struct sockaddr *)&addr, sizeof(addr));
-        ok(!ret || WSAGetLastError() == WSAEWOULDBLOCK, "got error %u\n", WSAGetLastError());
+        ok(ret == -1, "got %d\n", ret);
+        ok(WSAGetLastError() == WSAEWOULDBLOCK, "got error %u\n", WSAGetLastError());
 
         ret = WaitForSingleObject(event, 10000);
         ok(!ret, "got %#x\n", ret);
@@ -474,6 +475,7 @@ static void test_poll(void)
     server = accept(listener, NULL, NULL);
     ok(server != -1, "got error %u\n", WSAGetLastError());
 
+    in_params->timeout = -1000 * 10000;
     in_params->count = 2;
     in_params->sockets[0].socket = client;
     in_params->sockets[0].flags = AFD_POLL_READ;
@@ -1310,7 +1312,7 @@ static void test_get_events(void)
         ok(ret == -1, "expected failure\n");
         ok(WSAGetLastError() == WSAEWOULDBLOCK, "got error %u\n", WSAGetLastError());
 
-        ret = WaitForSingleObject(event, 2000);
+        ret = WaitForSingleObject(event, 10000);
         ok(!ret, "got %#x\n", ret);
 
         memset(&params, 0xcc, sizeof(params));
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 8617a6fb7e3..1fd75dc40d8 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -3252,17 +3252,20 @@ static void test_select(void)
         FD_SET(fdWrite, &exceptfds);
         select_timeout.tv_sec = 10;
         ret = select(0, &readfds, &writefds, &exceptfds, &select_timeout);
-        ok(ret == 1, "expected 1, got %d\n", ret);
+        todo_wine ok(ret == 1, "expected 1, got %d\n", ret);
         len = sizeof(id);
         id = 0xdeadbeef;
         ret = getsockopt(fdWrite, SOL_SOCKET, SO_ERROR, (char*)&id, &len);
         ok(!ret, "getsockopt failed with %d\n", WSAGetLastError());
-        ok(id == WSAECONNREFUSED, "expected 10061, got %d\n", id);
-        ok(FD_ISSET(fdWrite, &exceptfds), "fdWrite socket is not in the set\n");
+        todo_wine ok(id == WSAECONNREFUSED, "got error %u\n", id);
+        todo_wine ok(FD_ISSET(fdWrite, &exceptfds), "fdWrite socket is not in the set\n");
         ok(select_timeout.tv_usec == 250000, "select timeout should not have changed\n");
         closesocket(fdWrite);
     }
 
+    select_timeout.tv_sec = 1;
+    select_timeout.tv_usec = 250000;
+
     /* Try select() on a closed socket after connection */
     tcp_socketpair(&fdRead, &fdWrite);
     closesocket(fdRead);
@@ -6372,22 +6375,33 @@ static void test_WSAPoll(void)
      * so make the test interactive-only. */
     if (winetest_interactive)
     {
-        const struct sockaddr_in invalid_addr = {.sin_family = AF_INET, .sin_addr.s_addr = inet_addr("192.0.2.0")};
+        const struct sockaddr_in invalid_addr =
+        {
+            .sin_family = AF_INET,
+            .sin_addr.s_addr = htonl(INADDR_LOOPBACK),
+            .sin_port = 255,
+        };
+        SOCKET client;
 
-        client = setup_connector_socket(&invalid_addr, sizeof(invalid_addr), TRUE);
+        client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+        set_blocking(client, FALSE);
+
+        ret = connect(client, (const struct sockaddr *)&invalid_addr, sizeof(invalid_addr));
+        ok(ret == -1, "got %d\n", ret);
+        ok(WSAGetLastError() == WSAEWOULDBLOCK, "got error %u\n", WSAGetLastError());
 
         fds[0].fd = client;
         fds[0].events = POLLRDNORM | POLLRDBAND | POLLWRNORM;
         fds[0].revents = 0xdead;
         ret = pWSAPoll(fds, 1, 10000);
-        ok(ret == 1, "got %d\n", ret);
-        ok(fds[0].revents == POLLERR, "got events %#x\n", fds[0].revents);
+        todo_wine ok(ret == 1, "got %d\n", ret);
+        todo_wine ok(fds[0].revents == (POLLWRNORM | POLLHUP | POLLERR), "got events %#x\n", fds[0].revents);
 
         len = sizeof(err);
         err = 0xdeadbeef;
         ret = getsockopt(client, SOL_SOCKET, SO_ERROR, (char *)&err, &len);
         ok(!ret, "getsockopt failed with %d\n", WSAGetLastError());
-        ok(err == WSAECONNREFUSED, "expected 10061, got %d\n", err);
+        todo_wine ok(err == WSAECONNREFUSED, "got error %u\n", err);
         closesocket(client);
     }
 
-- 
2.30.2




More information about the wine-devel mailing list