Commit a799ad05b3

lithdew <kenta@lithdew.net>
2021-05-02 09:50:56
x/net/tcp: make tcp tests blocking to avoid unit test races
1 parent aa15699
Changed files (1)
lib
std
x
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();
 }