From a799ad05b37c4b04f73ad79f9e3c67c4036138ec Mon Sep 17 00:00:00 2001 From: lithdew Date: Sun, 2 May 2021 16:50:56 +0900 Subject: [PATCH] x/net/tcp: make tcp tests blocking to avoid unit test races --- lib/std/x/net/tcp.zig | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/std/x/net/tcp.zig b/lib/std/x/net/tcp.zig index 70cbc52f4e..9804699f48 100644 --- a/lib/std/x/net/tcp.zig +++ b/lib/std/x/net/tcp.zig @@ -316,10 +316,10 @@ pub const Listener = struct { } }; -test "tcp: create non-blocking pair" { +test "tcp: create client/listener pair" { if (builtin.os.tag == .wasi) return error.SkipZigTest; - const listener = try tcp.Listener.init(.ip, os.SOCK_NONBLOCK | os.SOCK_CLOEXEC); + const listener = try tcp.Listener.init(.ip, os.SOCK_CLOEXEC); defer listener.deinit(); try listener.bind(tcp.Address.initIPv4(IPv4.unspecified, 0)); @@ -327,13 +327,12 @@ test "tcp: create non-blocking pair" { const binded_address = try listener.getLocalAddress(); - const client = try tcp.Client.init(.ip, os.SOCK_NONBLOCK | os.SOCK_CLOEXEC); + const client = try tcp.Client.init(.ip, os.SOCK_CLOEXEC); defer client.deinit(); - testing.expectError(error.WouldBlock, client.connect(binded_address)); - try client.getError(); + try client.connect(binded_address); - const conn = try listener.accept(os.SOCK_NONBLOCK | os.SOCK_CLOEXEC); + const conn = try listener.accept(os.SOCK_CLOEXEC); defer conn.deinit(); }