| ... | ... | @@ -296,6 +296,21 @@ test "listen on a unix socket, send bytes, receive bytes" { |
| 296 | 296 | try testing.expectEqualSlices(u8, "Hello world!", buf[0..n]); |
| 297 | 297 | } |
| 298 | 298 | |
| 299 | test "listen on a unix socket with reuse_port option" { |
| 300 | if (!net.has_unix_sockets) return error.SkipZigTest; |
| 301 | // Windows doesn't implement reuse port option. |
| 302 | if (builtin.os.tag == .windows) return error.SkipZigTest; |
| 303 | |
| 304 | const socket_path = try generateFileName("socket.unix"); |
| 305 | defer testing.allocator.free(socket_path); |
| 306 | |
| 307 | const socket_addr = try net.Address.initUnix(socket_path); |
| 308 | defer std.fs.cwd().deleteFile(socket_path) catch {}; |
| 309 | |
| 310 | var server = try socket_addr.listen(.{ .reuse_port = true }); |
| 311 | server.deinit(); |
| 312 | } |
| 313 | |
| 299 | 314 | fn generateFileName(base_name: []const u8) ![]const u8 { |
| 300 | 315 | const random_bytes_count = 12; |
| 301 | 316 | const sub_path_len = comptime std.fs.base64_encoder.calcSize(random_bytes_count); |