Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ws2_32/tests/afd.c | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
diff --git a/dlls/ws2_32/tests/afd.c b/dlls/ws2_32/tests/afd.c index e385715f102..9d1600a7f6a 100644 --- a/dlls/ws2_32/tests/afd.c +++ b/dlls/ws2_32/tests/afd.c @@ -154,11 +154,14 @@ static void test_poll(void) struct afd_poll_params *out_params = (struct afd_poll_params *)out_buffer; int large_buffer_size = 1024 * 1024; SOCKET client, server, listener; + OVERLAPPED overlapped = {0}; struct sockaddr_in addr; + DWORD size, flags = 0; char *large_buffer; IO_STATUS_BLOCK io; LARGE_INTEGER now; ULONG params_size; + WSABUF wsabuf; HANDLE event; int ret, len;
@@ -166,6 +169,7 @@ static void test_poll(void) memset(in_buffer, 0, sizeof(in_buffer)); memset(out_buffer, 0, sizeof(out_buffer)); event = CreateEventW(NULL, TRUE, FALSE, NULL); + overlapped.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); ret = bind(listener, (const struct sockaddr *)&bind_addr, sizeof(bind_addr)); @@ -329,6 +333,50 @@ static void test_poll(void) check_poll(client, event, AFD_POLL_WRITE | AFD_POLL_CONNECT | AFD_POLL_READ); check_poll(server, event, AFD_POLL_CONNECT);
+ /* Test sending data while there is a pending WSARecv(). */ + + in_params->timeout = -1000 * 10000; + in_params->count = 1; + in_params->sockets[0].socket = server; + in_params->sockets[0].flags = AFD_POLL_READ; + + ret = NtDeviceIoControlFile((HANDLE)server, event, NULL, NULL, &io, + IOCTL_AFD_POLL, in_params, params_size, out_params, params_size); + ok(ret == STATUS_PENDING, "got %#x\n", ret); + + wsabuf.buf = large_buffer; + wsabuf.len = 1; + ret = WSARecv(server, &wsabuf, 1, NULL, &flags, &overlapped, NULL); + ok(ret == -1, "got %d\n", ret); + ok(WSAGetLastError() == ERROR_IO_PENDING, "got error %u\n", WSAGetLastError()); + + ret = send(client, "a", 1, 0); + ok(ret == 1, "got %d\n", ret); + + ret = WaitForSingleObject(overlapped.hEvent, 200); + ok(!ret, "got %d\n", ret); + ret = GetOverlappedResult((HANDLE)server, &overlapped, &size, FALSE); + ok(ret, "got error %lu\n", GetLastError()); + ok(size == 1, "got size %lu\n", size); + + ret = WaitForSingleObject(event, 0); + todo_wine ok(ret == WAIT_TIMEOUT, "got %#x\n", ret); + + ret = send(client, "a", 1, 0); + ok(ret == 1, "got %d\n", ret); + + ret = WaitForSingleObject(event, 200); + ok(!ret, "got %#x\n", ret); + ok(!io.Status, "got %#lx\n", io.Status); + ok(io.Information == offsetof(struct afd_poll_params, sockets[1]), "got %#Ix\n", io.Information); + ok(out_params->count == 1, "got count %u\n", out_params->count); + ok(out_params->sockets[0].socket == server, "got socket %#Ix\n", out_params->sockets[0].socket); + ok(out_params->sockets[0].flags == AFD_POLL_READ, "got flags %#x\n", out_params->sockets[0].flags); + ok(!out_params->sockets[0].status, "got status %#x\n", out_params->sockets[0].status); + + ret = recv(server, large_buffer, 1, 0); + ok(ret == 1, "got %d\n", ret); + /* Test sending out-of-band data. */
ret = send(client, "a", 1, MSG_OOB); @@ -745,6 +793,7 @@ static void test_poll(void) closesocket(client); closesocket(server);
+ CloseHandle(overlapped.hEvent); CloseHandle(event); free(large_buffer); }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ws2_32/tests/afd.c | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
diff --git a/dlls/ws2_32/tests/afd.c b/dlls/ws2_32/tests/afd.c index 9d1600a7f6a..5152469f02f 100644 --- a/dlls/ws2_32/tests/afd.c +++ b/dlls/ws2_32/tests/afd.c @@ -153,8 +153,10 @@ static void test_poll(void) struct afd_poll_params *in_params = (struct afd_poll_params *)in_buffer; struct afd_poll_params *out_params = (struct afd_poll_params *)out_buffer; int large_buffer_size = 1024 * 1024; + GUID acceptex_guid = WSAID_ACCEPTEX; SOCKET client, server, listener; OVERLAPPED overlapped = {0}; + LPFN_ACCEPTEX pAcceptEx; struct sockaddr_in addr; DWORD size, flags = 0; char *large_buffer; @@ -180,6 +182,10 @@ static void test_poll(void) ret = getsockname(listener, (struct sockaddr *)&addr, &len); ok(!ret, "got error %u\n", WSAGetLastError());
+ ret = WSAIoctl(listener, SIO_GET_EXTENSION_FUNCTION_POINTER, &acceptex_guid, sizeof(acceptex_guid), + &pAcceptEx, sizeof(pAcceptEx), &size, NULL, NULL); + ok(!ret, "failed to get AcceptEx, error %u\n", WSAGetLastError()); + params_size = offsetof(struct afd_poll_params, sockets[1]); in_params->count = 1;
@@ -673,6 +679,52 @@ static void test_poll(void)
closesocket(client);
+ /* Test connecting while there is a pending AcceptEx(). */ + + in_params->timeout = -1000 * 10000; + in_params->count = 1; + in_params->sockets[0].socket = listener; + in_params->sockets[0].flags = AFD_POLL_ACCEPT; + + ret = NtDeviceIoControlFile((HANDLE)listener, event, NULL, NULL, &io, + IOCTL_AFD_POLL, in_params, params_size, out_params, params_size); + ok(ret == STATUS_PENDING, "got %#x\n", ret); + + server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = pAcceptEx(listener, server, large_buffer, 0, 0, sizeof(struct sockaddr_in) + 16, NULL, &overlapped); + ok(!ret, "got %d\n", ret); + ok(WSAGetLastError() == ERROR_IO_PENDING, "got error %u\n", WSAGetLastError()); + + client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = connect(client, (struct sockaddr *)&addr, sizeof(addr)); + ok(!ret, "got error %u\n", WSAGetLastError()); + + ret = WaitForSingleObject(overlapped.hEvent, 200); + ok(!ret, "got %d\n", ret); + ret = GetOverlappedResult((HANDLE)listener, &overlapped, &size, FALSE); + ok(ret, "got error %lu\n", GetLastError()); + ok(!size, "got size %lu\n", size); + + ret = WaitForSingleObject(event, 0); + todo_wine ok(ret == WAIT_TIMEOUT, "got %#x\n", ret); + + closesocket(server); + closesocket(client); + + client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = connect(client, (struct sockaddr *)&addr, sizeof(addr)); + ok(!ret, "got error %u\n", WSAGetLastError()); + + ret = WaitForSingleObject(event, 200); + ok(!ret, "got %#x\n", ret); + ok(!io.Status, "got %#lx\n", io.Status); + ok(io.Information == offsetof(struct afd_poll_params, sockets[1]), "got %#Ix\n", io.Information); + ok(out_params->count == 1, "got count %u\n", out_params->count); + ok(out_params->sockets[0].socket == listener, "got socket %#Ix\n", out_params->sockets[0].socket); + ok(out_params->sockets[0].flags == AFD_POLL_ACCEPT, "got flags %#x\n", out_params->sockets[0].flags); + ok(!out_params->sockets[0].status, "got status %#x\n", out_params->sockets[0].status); + + closesocket(client); closesocket(listener);
/* Test UDP sockets. */
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ws2_32/tests/sock.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 5efff0420eb..2ad649816eb 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -5709,11 +5709,16 @@ static void test_write_events(struct event_test_ctx *ctx)
static void test_read_events(struct event_test_ctx *ctx) { + OVERLAPPED overlapped = {0}; SOCKET server, client; + DWORD size, flags = 0; unsigned int i; char buffer[8]; + WSABUF wsabuf; int ret;
+ overlapped.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL); + tcp_socketpair(&client, &server); set_blocking(client, FALSE);
@@ -5788,8 +5793,36 @@ static void test_read_events(struct event_test_ctx *ctx)
check_events(ctx, 0, 0, 200);
+ /* Send data while there is a pending WSARecv(). */ + + select_events(ctx, server, FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_OOB | FD_READ); + + wsabuf.buf = buffer; + wsabuf.len = 1; + ret = WSARecv(server, &wsabuf, 1, NULL, &flags, &overlapped, NULL); + ok(ret == -1, "got %d\n", ret); + ok(WSAGetLastError() == ERROR_IO_PENDING, "got error %u\n", WSAGetLastError()); + + ret = send(client, "a", 1, 0); + ok(ret == 1, "got %d\n", ret); + + ret = WaitForSingleObject(overlapped.hEvent, 200); + ok(!ret, "got %d\n", ret); + ret = GetOverlappedResult((HANDLE)server, &overlapped, &size, FALSE); + ok(ret, "got error %lu\n", GetLastError()); + ok(size == 1, "got size %lu\n", size); + + check_events(ctx, 0, 0, 0); + + ret = send(client, "a", 1, 0); + ok(ret == 1, "got %d\n", ret); + + check_events(ctx, FD_READ, 0, 200); + check_events(ctx, 0, 0, 0); + closesocket(server); closesocket(client); + CloseHandle(overlapped.hEvent); }
static void test_oob_events(struct event_test_ctx *ctx)
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ws2_32/tests/sock.c | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 2ad649816eb..78c778586a8 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -5308,12 +5308,23 @@ static void test_accept_events(struct event_test_ctx *ctx) { const struct sockaddr_in addr = {.sin_family = AF_INET, .sin_addr.s_addr = htonl(INADDR_LOOPBACK)}; SOCKET listener, server, client, client2; + GUID acceptex_guid = WSAID_ACCEPTEX; struct sockaddr_in destaddr; + OVERLAPPED overlapped = {0}; + LPFN_ACCEPTEX pAcceptEx; + char buffer[32]; int len, ret; + DWORD size; + + overlapped.hEvent = CreateEventA(NULL, TRUE, FALSE, NULL);
listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); ok(listener != -1, "failed to create socket, error %u\n", WSAGetLastError());
+ ret = WSAIoctl(listener, SIO_GET_EXTENSION_FUNCTION_POINTER, &acceptex_guid, sizeof(acceptex_guid), + &pAcceptEx, sizeof(pAcceptEx), &size, NULL, NULL); + ok(!ret, "failed to get AcceptEx, error %u\n", WSAGetLastError()); + select_events(ctx, listener, FD_CONNECT | FD_READ | FD_OOB | FD_ACCEPT);
ret = bind(listener, (const struct sockaddr *)&addr, sizeof(addr)); @@ -5511,7 +5522,44 @@ static void test_accept_events(struct event_test_ctx *ctx) closesocket(server); closesocket(client);
+ /* Connect while there is a pending AcceptEx(). */ + + select_events(ctx, listener, FD_CONNECT | FD_READ | FD_OOB | FD_ACCEPT); + + server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = pAcceptEx(listener, server, buffer, 0, 0, sizeof(buffer), NULL, &overlapped); + ok(!ret, "got %d\n", ret); + ok(WSAGetLastError() == ERROR_IO_PENDING, "got error %u\n", WSAGetLastError()); + + client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = connect(client, (struct sockaddr *)&destaddr, sizeof(destaddr)); + ok(!ret, "got error %u\n", WSAGetLastError()); + + ret = WaitForSingleObject(overlapped.hEvent, 200); + ok(!ret, "got %d\n", ret); + ret = GetOverlappedResult((HANDLE)listener, &overlapped, &size, FALSE); + ok(ret, "got error %lu\n", GetLastError()); + ok(!size, "got size %lu\n", size); + + check_events_todo(ctx, 0, 0, 0); + + closesocket(server); + closesocket(client); + + client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ret = connect(client, (struct sockaddr *)&destaddr, sizeof(destaddr)); + ok(!ret, "got error %u\n", WSAGetLastError()); + + check_events_todo(ctx, FD_ACCEPT, 0, 200); + check_events(ctx, 0, 0, 0); + + server = accept(listener, NULL, NULL); + ok(server != -1, "failed to accept, error %u\n", WSAGetLastError()); + closesocket(server); + closesocket(client); + closesocket(listener); + CloseHandle(overlapped.hEvent); }
static void test_connect_events(struct event_test_ctx *ctx)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=113806
Your paranoid android.
=== debian11 (32 bit Hebrew:Israel report) ===
ws2_32: sock.c:5592: Test failed: expected timeout
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/ws2_32/tests/afd.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
diff --git a/dlls/ws2_32/tests/afd.c b/dlls/ws2_32/tests/afd.c index 5152469f02f..43c401c940a 100644 --- a/dlls/ws2_32/tests/afd.c +++ b/dlls/ws2_32/tests/afd.c @@ -724,7 +724,42 @@ static void test_poll(void) ok(out_params->sockets[0].flags == AFD_POLL_ACCEPT, "got flags %#x\n", out_params->sockets[0].flags); ok(!out_params->sockets[0].status, "got status %#x\n", out_params->sockets[0].status);
+ server = accept(listener, NULL, NULL); + ok(server != -1, "got error %u\n", WSAGetLastError()); + closesocket(server); closesocket(client); + + /* Verify that CONNECT and WRITE are signaled simultaneously. */ + + client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + + in_params->timeout = -1000 * 10000; + in_params->count = 1; + in_params->sockets[0].socket = client; + in_params->sockets[0].flags = ~0; + params_size = offsetof(struct afd_poll_params, sockets[1]); + + ret = NtDeviceIoControlFile((HANDLE)client, event, NULL, NULL, &io, + IOCTL_AFD_POLL, in_params, params_size, out_params, params_size); + ok(ret == STATUS_PENDING, "got %#x\n", ret); + + ret = connect(client, (struct sockaddr *)&addr, sizeof(addr)); + ok(!ret, "got error %u\n", WSAGetLastError()); + + ret = WaitForSingleObject(event, 200); + ok(!ret, "got %#x\n", ret); + ok(!io.Status, "got %#lx\n", io.Status); + ok(io.Information == offsetof(struct afd_poll_params, sockets[1]), "got %#Ix\n", io.Information); + ok(out_params->count == 1, "got count %u\n", out_params->count); + ok(out_params->sockets[0].flags == (AFD_POLL_CONNECT | AFD_POLL_WRITE), + "got flags %#x\n", out_params->sockets[0].flags); + ok(!out_params->sockets[0].status, "got status %#x\n", out_params->sockets[0].status); + + server = accept(listener, NULL, NULL); + ok(server != -1, "got error %u\n", WSAGetLastError()); + closesocket(server); + closesocket(client); + closesocket(listener);
/* Test UDP sockets. */