From 131f91352724ace6379804bf91994d37aa1e8f88 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Wed, 5 Jan 2022 19:03:03 -0600 Subject: [PATCH] ws2_32/tests: Test whether WSAEventSelect() modifies the event state. Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/ws2_32/tests/sock.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index 5cf015eecc6..aa95e2a3dfa 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -5133,6 +5133,42 @@ static void test_accept_events(struct event_test_ctx *ctx) closesocket(server); closesocket(client); + /* As above, but select on a subset containing FD_ACCEPT first. */ + + if (!ctx->is_message) + { + select_events(ctx, listener, FD_CONNECT | FD_READ | FD_OOB | FD_ACCEPT); + + client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); + ok(client != -1, "failed to create socket, error %u\n", WSAGetLastError()); + ret = connect(client, (struct sockaddr *)&destaddr, sizeof(destaddr)); + ok(!ret, "failed to connect, error %u\n", WSAGetLastError()); + + ret = WaitForSingleObject(ctx->event, 200); + ok(!ret, "wait timed out\n"); + + select_events(ctx, listener, FD_CONNECT | FD_READ | FD_OOB); + ret = WaitForSingleObject(ctx->event, 0); + ok(!ret, "wait timed out\n"); + + ResetEvent(ctx->event); + + select_events(ctx, listener, FD_CONNECT | FD_READ | FD_OOB); + ret = WaitForSingleObject(ctx->event, 0); + ok(ret == WAIT_TIMEOUT, "expected timeout\n"); + + select_events(ctx, listener, FD_CONNECT | FD_READ | FD_OOB | FD_ACCEPT); + ret = WaitForSingleObject(ctx->event, 0); + todo_wine ok(!ret, "wait timed out\n"); + if (!ret) + check_events(ctx, FD_ACCEPT, 0, 0); + + server = accept(listener, NULL, NULL); + ok(server != -1, "failed to accept, error %u\n", WSAGetLastError()); + closesocket(server); + closesocket(client); + } + /* As above, but select on a subset not containing FD_ACCEPT first. */ select_events(ctx, listener, FD_CONNECT | FD_READ | FD_OOB);