Lightpanda: the headless browser designed for AI and automation
test: simplify the parallel runner and port routing
Adrià Arrufat7cd4863c4835
diff --git a/src/TestHTTPServer.zig b/src/TestHTTPServer.zigindex 6f2d6e47f..f0d4481c9 100644--- a/src/TestHTTPServer.zig+++ b/src/TestHTTPServer.zig@@ -28,8 +28,6 @@ const TestHTTPServer = @This();shutdown: std.atomic.Value(bool),listener: ?std.Io.net.Server,handler: Handler,-// ephemeral, known once run() has signaled the wait group-port: u16,const Handler = *const fn (req: *std.http.Server.Request) anyerror!void;@@ -38,7 +36,6 @@ pub fn init(handler: Handler) TestHTTPServer {.shutdown = .init(true),.listener = null,.handler = handler,- .port = 0,};}@@ -61,7 +58,6 @@ pub fn run(self: *TestHTTPServer, wg: *lp.WaitGroup) !void {self.listener = try address.listen(lp.io, .{ .reuse_address = true });var listener = &self.listener.?;- self.port = listener.socket.address.getPort();self.shutdown.store(false, .release);wg.finish();diff --git a/src/TestWSServer.zig b/src/TestWSServer.zigindex ccf239cec..488c06332 100644--- a/src/TestWSServer.zig+++ b/src/TestWSServer.zig@@ -64,10 +64,7 @@ fn runImpl(self: *TestWSServer, wg: *lp.WaitGroup) !void {try sys_net.bind(socket, sa.ptr(), sa.len);try sys_net.listen(socket, 8);- var bound: posix.sockaddr.storage = undefined;- var bound_len: posix.socklen_t = @sizeOf(posix.sockaddr.storage);- try sys_net.getsockname(socket, @ptrCast(&bound), &bound_len);- self.port = sys_net.addressFromSockaddr(@ptrCast(&bound)).getPort();+ self.port = (try sys_net.boundAddress(socket)).getPort();self.listener = socket;self.shutdown.store(false, .release);diff --git a/src/mcp/HttpServer.zig b/src/mcp/HttpServer.zigindex 427868594..a14f34413 100644--- a/src/mcp/HttpServer.zig+++ b/src/mcp/HttpServer.zig@@ -204,10 +204,7 @@ pub fn run(self: *HttpServer, address: sys_net.IpAddress) !void {try sys_net.listen(listener, self.app.config.maxPendingConnections());// --port 0 asks the OS for an ephemeral port; log the one we actually got.- var bound: posix.sockaddr.storage = undefined;- var bound_len: posix.socklen_t = @sizeOf(posix.sockaddr.storage);- try sys_net.getsockname(listener, @ptrCast(&bound), &bound_len);- log.note(.mcp, "mcp http server running", .{ .address = sys_net.addressFromSockaddr(@ptrCast(&bound)) });+ log.note(.mcp, "mcp http server running", .{ .address = try sys_net.boundAddress(listener) });self.listener = listener;// On non-Linux stop() closes the listener itself to unblock accept.diff --git a/src/mcp/tools.zig b/src/mcp/tools.zigindex 899f4df8f..438e4b679 100644--- a/src/mcp/tools.zig+++ b/src/mcp/tools.zig@@ -1172,7 +1172,7 @@ test "MCP - save writes the script to disk" {var tmp = std.testing.tmpDir(.{});defer tmp.cleanup();- const path = try testing.arena_allocator.print(".zig-cache/tmp/{s}/script.js", .{&tmp.sub_path});+ const path = try testing.tmpPath(&tmp, "script.js");const msg = try testing.arena_allocator.print(\\{{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{{"name":"save","arguments":{{"path":"{s}","script":"const page = new Page();\nawait page.goto(\"https://example.com\");"}}}}}}@@ -1841,7 +1841,7 @@ test "MCP - screenshot: inline image, file, unsafe path" {var tmp = std.testing.tmpDir(.{});defer tmp.cleanup();- const path = try testing.arena_allocator.print(".zig-cache/tmp/{s}/screenshot.png", .{&tmp.sub_path});+ const path = try testing.tmpPath(&tmp, "screenshot.png");out.clearRetainingCapacity();const to_file = try testing.arena_allocator.print("{{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/call\",\"params\":{{\"name\":\"screenshot\",\"arguments\":{{\"path\":\"{s}\",\"selector\":\"#hoverTarget\"}}}}}}", .{path});diff --git a/src/network/http.zig b/src/network/http.zigindex 29823b9d7..d6f840f84 100644--- a/src/network/http.zig+++ b/src/network/http.zig@@ -18,7 +18,6 @@const std = @import("std");const lp = @import("lightpanda");-const builtin = @import("builtin");const Config = @import("../Config.zig");const sys_net = @import("../sys/net.zig");@@ -289,9 +288,6 @@ pub const Connection = struct {pub fn setURL(self: *const Connection, url: [:0]const u8) !void {try libcurl.curl_easy_setopt(self._easy, .url, url.ptr);- if (comptime builtin.is_test) {- try libcurl.curl_easy_setopt(self._easy, .connect_to, test_connect_to);- }}pub fn setTimeout(self: *const Connection, timeout_ms: u32) !void {@@ -466,6 +462,10 @@ pub const Connection = struct {// empty string means: use whatever's availabletry libcurl.curl_easy_setopt(self._easy, .accept_encoding, "");+ if (comptime lp.IS_TEST) {+ try libcurl.curl_easy_setopt(self._easy, .connect_to, test_connect_to);+ }+// proxyconst http_proxy = config.httpProxy();if (http_proxy) |proxy| {diff --git a/src/server/Server.zig b/src/server/Server.zigindex 269402a06..3cbb47729 100644--- a/src/server/Server.zig+++ b/src/server/Server.zig@@ -151,10 +151,7 @@ pub fn init(app: *App, address: sys_net.IpAddress) !*Server {try sys_net.bind(l, sa.ptr(), sa.len);{// look this up incase --port 0 was used- var bound: posix.sockaddr.storage = undefined;- var bound_len: posix.socklen_t = @sizeOf(posix.sockaddr.storage);- try sys_net.getsockname(l, @ptrCast(&bound), &bound_len);- const bound_address = sys_net.addressFromSockaddr(@ptrCast(&bound));+ const bound_address = try sys_net.boundAddress(l);json_version_response = try http.buildJSONVersionResponse(app, bound_address.getPort());errdefer allocator.free(json_version_response);@@ -3396,11 +3393,7 @@ const LoopTest = struct {// run() does this; runOnce() on its own would never see an accepttry server.io_engine.monitorListener(server.listener);- var bound: posix.sockaddr.storage = undefined;- var bound_len: posix.socklen_t = @sizeOf(posix.sockaddr.storage);- try sys_net.getsockname(server.listener, @ptrCast(&bound), &bound_len);-- return .{ .server = server, .address = sys_net.addressFromSockaddr(@ptrCast(&bound)) };+ return .{ .server = server, .address = try sys_net.boundAddress(server.listener) };}fn deinit(self: *LoopTest) void {diff --git a/src/server/cdp/domains/dom.zig b/src/server/cdp/domains/dom.zigindex cc2487783..7c740aa2d 100644--- a/src/server/cdp/domains/dom.zig+++ b/src/server/cdp/domains/dom.zig@@ -958,10 +958,6 @@ test "cdp.dom: focus errors on an element that can't take focus" {try testing.expect(result.isTrue());}-fn tmpPath(tmp: *const std.testing.TmpDir, name: []const u8) ![]const u8 {- return testing.arena_allocator.print(".zig-cache/tmp/{s}/{s}", .{ &tmp.sub_path, name });-}-test "cdp.dom: setFileInputFiles on file input" {var ctx = try testing.context();defer ctx.deinit();@@ -986,9 +982,8 @@ test "cdp.dom: setFileInputFiles on file input" {// Drop a temp file we can upload.var tmp = std.testing.tmpDir(.{});defer tmp.cleanup();- const tmp_dir = tmp.dir;{- const f = try tmp_dir.createFile(lp.io, "upload.txt", .{ .truncate = true });+ const f = try tmp.dir.createFile(lp.io, "upload.txt", .{ .truncate = true });defer f.close(lp.io);try f.writeStreamingAll(lp.io, "hello upload");}@@ -998,7 +993,7 @@ test "cdp.dom: setFileInputFiles on file input" {.method = "DOM.setFileInputFiles",.params = .{.nodeId = 1,- .files = &[_][]const u8{try tmpPath(&tmp, "upload.txt")},+ .files = &[_][]const u8{try testing.tmpPath(&tmp, "upload.txt")},},});try ctx.expectSentResult(null, .{ .id = 3 });@@ -1022,12 +1017,11 @@ test "cdp.dom: setFileInputFiles exposes files to JS" {// Two files, so we can assert ordering as well as identity and iteration.var tmp = std.testing.tmpDir(.{});defer tmp.cleanup();- const tmp_dir = tmp.dir;{- const a = try tmp_dir.createFile(lp.io, "a.txt", .{ .truncate = true });+ const a = try tmp.dir.createFile(lp.io, "a.txt", .{ .truncate = true });defer a.close(lp.io);try a.writeStreamingAll(lp.io, "aaa");- const b = try tmp_dir.createFile(lp.io, "b.txt", .{ .truncate = true });+ const b = try tmp.dir.createFile(lp.io, "b.txt", .{ .truncate = true });defer b.close(lp.io);try b.writeStreamingAll(lp.io, "bbbb");}@@ -1052,7 +1046,7 @@ test "cdp.dom: setFileInputFiles exposes files to JS" {.method = "DOM.setFileInputFiles",.params = .{.nodeId = 1,- .files = &[_][]const u8{ try tmpPath(&tmp, "a.txt"), try tmpPath(&tmp, "b.txt") },+ .files = &[_][]const u8{ try testing.tmpPath(&tmp, "a.txt"), try testing.tmpPath(&tmp, "b.txt") },},});try ctx.expectSentResult(null, .{ .id = 3 });@@ -1144,9 +1138,8 @@ test "cdp.dom: setFileInputFiles errors when a path is missing" {// freed when the second read fails (the test runner panics on a leak).var tmp = std.testing.tmpDir(.{});defer tmp.cleanup();- const tmp_dir = tmp.dir;{- const f = try tmp_dir.createFile(lp.io, "upload.txt", .{ .truncate = true });+ const f = try tmp.dir.createFile(lp.io, "upload.txt", .{ .truncate = true });defer f.close(lp.io);try f.writeStreamingAll(lp.io, "hello upload");}@@ -1156,7 +1149,7 @@ test "cdp.dom: setFileInputFiles errors when a path is missing" {.method = "DOM.setFileInputFiles",.params = .{.nodeId = 1,- .files = &[_][]const u8{ try tmpPath(&tmp, "upload.txt"), try tmpPath(&tmp, "does-not-exist.txt") },+ .files = &[_][]const u8{ try testing.tmpPath(&tmp, "upload.txt"), try testing.tmpPath(&tmp, "does-not-exist.txt") },},});try ctx.expectSentError(-31998, "FileNotFound", .{ .id = 3 });@@ -1176,9 +1169,8 @@ test "cdp.dom: focus and setFileInputFiles fire in the node's own frame" {var tmp = std.testing.tmpDir(.{});defer tmp.cleanup();- const tmp_dir = tmp.dir;{- const f = try tmp_dir.createFile(lp.io, "upload.txt", .{ .truncate = true });+ const f = try tmp.dir.createFile(lp.io, "upload.txt", .{ .truncate = true });defer f.close(lp.io);try f.writeStreamingAll(lp.io, "hello upload");}@@ -1190,7 +1182,7 @@ test "cdp.dom: focus and setFileInputFiles fire in the node's own frame" {.method = "DOM.setFileInputFiles",.params = .{.nodeId = upload_node.id,- .files = &[_][]const u8{try tmpPath(&tmp, "upload.txt")},+ .files = &[_][]const u8{try testing.tmpPath(&tmp, "upload.txt")},},});try ctx.expectSentResult(null, .{ .id = 2 });diff --git a/src/server/cdp/testing.zig b/src/server/cdp/testing.zigindex f6f03b691..0f63877d0 100644--- a/src/server/cdp/testing.zig+++ b/src/server/cdp/testing.zig@@ -39,6 +39,7 @@ pub const pageTest = base.pageTest;pub const newString = base.newString;pub const expectLog = base.expectLog;pub const silenceLog = base.silenceLog;+pub const tmpPath = base.tmpPath;pub const arena_allocator = base.arena_allocator;pub const TestContext = struct {diff --git a/src/storage/sqlite/Pool.zig b/src/storage/sqlite/Pool.zigindex 4733d1688..c5c8438e9 100644--- a/src/storage/sqlite/Pool.zig+++ b/src/storage/sqlite/Pool.zig@@ -103,8 +103,7 @@ test "Sqlite: Pool" {// that useful for testing. So we create a temp file.var tmp = std.testing.tmpDir(.{});defer tmp.cleanup();- const dir = try tmp.dir.realPathFileAlloc(testing.io, ".", testing.arena_allocator);- const path = try testing.arena_allocator.printSentinel("{s}/pool.sqlite", .{dir}, 0);+ const path = try testing.tmpPath(&tmp, "pool.sqlite");var pool = try Pool.init(testing.allocator, path);defer pool.deinit(testing.allocator);diff --git a/src/sys/net.zig b/src/sys/net.zigindex 38024e3c8..01bdfc0d9 100644--- a/src/sys/net.zig+++ b/src/sys/net.zig@@ -180,6 +180,14 @@ pub fn getsockname(sock: socket_t, addr: *posix.sockaddr, len: *posix.socklen_t)}}+/// The address a socket is bound to, e.g. the ephemeral port picked for port 0.+pub fn boundAddress(sock: socket_t) !IpAddress {+ var bound: posix.sockaddr.storage = undefined;+ var bound_len: posix.socklen_t = @sizeOf(posix.sockaddr.storage);+ try getsockname(sock, @ptrCast(&bound), &bound_len);+ return addressFromSockaddr(@ptrCast(&bound));+}+pub fn connect(addr: *const IpAddress) !socket_t {const sock = try socket(family(addr), posix.SOCK.STREAM, posix.IPPROTO.TCP);errdefer _ = c.close(sock);diff --git a/src/test_runner.zig b/src/test_runner.zigindex 5c8071501..9f5d3e745 100644--- a/src/test_runner.zig+++ b/src/test_runner.zig@@ -52,7 +52,7 @@ pub fn main(init: std.process.Init) !void {const env = Env.init(init.environ_map);if (env.shard == null and env.jobs > 1) {- return runShards(std.testing.io_instance.io(), arena.allocator(), init.environ_map, env.jobs);+ try runShards(std.testing.io_instance.io(), arena.allocator(), init.environ_map, env.jobs);}var runner = Runner.init(allocator, arena.allocator(), &ta, env);@@ -249,10 +249,15 @@ const Runner = struct {if (self.env.report) |path| {const json = try std.json.Stringify.valueAlloc(self.arena, report, .{});try Io.Dir.cwd().writeFile(io, .{ .sub_path = path, .data = json });- std.process.exit(if (fail == 0) 0 else 1);+ } else {+ try self.printReport(io, report, ns_duration);}- report.print(&slowest);+ std.process.exit(if (fail == 0) 0 else 1);+ }++ fn printReport(self: *Runner, io: Io, report: Report, ns_duration: u64) !void {+ report.print();// statsif (self.env.metrics) {Printer.fmt("\n", .{});@@ -277,12 +282,10 @@ const Runner = struct {}report.printFailed();-- std.process.exit(if (fail == 0) 0 else 1);}};-// What a shard hands back to the process that spawned it.+// A run's outcome. Shards send it to their parent as JSON.const Report = struct {pass: usize = 0,fail: usize = 0,@@ -291,7 +294,7 @@ const Report = struct {failed: []const []const u8 = &.{},slowest: []const SlowTracker.TestInfo = &.{},- fn print(self: *const Report, slowest: *SlowTracker) void {+ fn print(self: *const Report) void {const total_tests = self.pass + self.fail;const status = if (total_tests > 0 and self.fail == 0) Status.pass else Status.fail;Printer.status(status, "\n{d} of {d} test{s} passed\n", .{ self.pass, total_tests, if (total_tests != 1) "s" else "" });@@ -301,10 +304,13 @@ const Report = struct {if (self.leak > 0) {Printer.status(.fail, "{d} test{s} leaked\n", .{ self.leak, if (self.leak != 1) "s" else "" });}- for (self.slowest) |info| {- slowest.track(info.name, info.ns);+ if (self.slowest.len > 0) {+ Printer.fmt("\nSlowest {d} test{s}: \n", .{ self.slowest.len, if (self.slowest.len != 1) "s" else "" });+ for (self.slowest) |info| {+ const ms = @as(f64, @floatFromInt(info.ns)) / 1_000_000.0;+ Printer.fmt(" {d:.2}ms\t{s}\n", .{ ms, info.name });+ }}- slowest.display();}fn printFailed(self: *const Report) void {@@ -318,26 +324,26 @@ const Report = struct {};/// Runs the suite as `jobs` copies of this binary, each taking every jobs-th-/// test, and merges what they report. Never returns.-fn runShards(io: Io, arena: Allocator, environ_map: *const std.process.Environ.Map, jobs: usize) !void {+/// test, and merges what they report.+fn runShards(io: Io, arena: Allocator, environ_map: *const std.process.Environ.Map, jobs: usize) !noreturn {const exe = try std.process.executablePathAlloc(io, arena);- const dir = try std.fmt.allocPrint(arena, ".zig-cache/tmp/test-shards-{d}", .{std.c.getpid()});+ const dir = try arena.print(".zig-cache/tmp/test-shards-{d}", .{std.c.getpid()});try Io.Dir.cwd().createDirPath(io, dir);defer Io.Dir.cwd().deleteTree(io, dir) catch {};const children = try arena.alloc(std.process.Child, jobs);const report_paths = try arena.alloc([]const u8, jobs);for (children, report_paths, 0..) |*child, *report_path, i| {- report_path.* = try std.fmt.allocPrint(arena, "{s}/{d}.json", .{ dir, i });+ report_path.* = try arena.print("{s}/{d}.json", .{ dir, i });var child_env = try environ_map.clone(arena);- try child_env.put("TEST_SHARD", try std.fmt.allocPrint(arena, "{d}/{d}", .{ i, jobs }));+ try child_env.put("TEST_SHARD", try arena.print("{d}/{d}", .{ i, jobs }));try child_env.put("TEST_REPORT", report_path.*);child.* = try std.process.spawn(io, .{ .argv = &.{exe}, .environ_map = &child_env });}var total: Report = .{};var failed: std.ArrayList([]const u8) = .empty;- var slowest = SlowTracker.init(io, arena, 5);+ var slowest: SlowTracker = .init(io, arena, 5);var crashed = false;for (children, report_paths, 0..) |*child, report_path, i| {const term = try child.wait(io);@@ -357,8 +363,9 @@ fn runShards(io: Io, arena: Allocator, environ_map: *const std.process.Environ.M}}total.failed = failed.items;+ total.slowest = slowest.drain(arena);- total.print(&slowest);+ total.print();total.printFailed();std.process.exit(if (total.fail == 0 and !crashed) 0 else 1);}@@ -478,24 +485,11 @@ const SlowTracker = struct {/// Empties the tracker into a slice, fastest first.fn drain(self: *SlowTracker, allocator: Allocator) []const TestInfo {- var list: std.ArrayList(TestInfo) = .empty;- while (self.slowest.popMin()) |info| {- list.append(allocator, info) catch @panic("OOM");- }- return list.items;- }-- fn display(self: *SlowTracker) void {- var slowest = self.slowest;- const count = slowest.count();- if (count == 0) {- return;- }- Printer.fmt("\nSlowest {d} test{s}: \n", .{ count, if (count != 1) "s" else "" });- while (slowest.popMin()) |info| {- const ms = @as(f64, @floatFromInt(info.ns)) / 1_000_000.0;- Printer.fmt(" {d:.2}ms\t{s}\n", .{ ms, info.name });+ const out = allocator.alloc(TestInfo, self.slowest.count()) catch @panic("OOM");+ for (out) |*info| {+ info.* = self.slowest.popMin().?;}+ return out;}fn compareTiming(context: void, a: TestInfo, b: TestInfo) std.math.Order {@@ -552,9 +546,9 @@ const Env = struct {fn parseShard(value: ?[]const u8) ?Shard {const v = value orelse return null;- const split = std.mem.findScalar(u8, v, '/') orelse return null;- const index = std.fmt.parseInt(usize, v[0..split], 10) catch return null;- const count = std.fmt.parseInt(usize, v[split + 1 ..], 10) catch return null;+ const index_str, const count_str = std.mem.cutScalar(u8, v, '/') orelse return null;+ const index = std.fmt.parseInt(usize, index_str, 10) catch return null;+ const count = std.fmt.parseInt(usize, count_str, 10) catch return null;if (index >= count) return null;return .{ .index = index, .count = count };}diff --git a/src/testing.zig b/src/testing.zigindex d32985c45..69fbd5e88 100644--- a/src/testing.zig+++ b/src/testing.zig@@ -44,6 +44,12 @@ pub fn reset() void {_ = arena_instance.reset(.retain_capacity);}+/// Path of `name` inside a std.testing.tmpDir, relative to the cwd like the+/// tmpDir itself, since some tools refuse absolute paths.+pub fn tmpPath(tmp: *const std.testing.TmpDir, name: []const u8) ![:0]const u8 {+ return std.Io.Dir.path.joinZ(arena_allocator, &.{ ".zig-cache", "tmp", &tmp.sub_path, name });+}+const App = @import("App.zig");const js = @import("browser/js/js.zig");const Config = @import("Config.zig");@@ -539,6 +545,21 @@ test "tests:beforeAll" {const test_allocator = @import("root").tracking_allocator;+ // Before App.init: its connection pool picks up the routes as it's built.+ {+ var wg: lp.WaitGroup = .{};+ wg.startMany(2);++ test_http_server = TestHTTPServer.init(testHTTPHandler);+ test_http_server_thread = try std.Thread.spawn(.{}, TestHTTPServer.run, .{ &test_http_server.?, &wg });++ test_ws_server = TestWSServer.init();+ test_ws_server_thread = try std.Thread.spawn(.{}, TestWSServer.run, .{ &test_ws_server.?, &wg });++ wg.wait();+ try routeTestPorts();+ }+test_config = try Config.init(test_allocator, "test", .{.serve = .{.insecure_disable_tls_host_verification = true,@@ -561,41 +582,28 @@ test "tests:beforeAll" {test_session = try test_browser.newSession(test_notification);+ // need to wait for the server to be listening, else tests will fail because+ // they aren't able to connect.var wg: lp.WaitGroup = .{};- wg.startMany(3);-+ wg.startMany(1);test_cdp_server_thread = try std.Thread.spawn(.{}, serveCDP, .{&wg});-- test_http_server = TestHTTPServer.init(testHTTPHandler);- test_http_server_thread = try std.Thread.spawn(.{}, TestHTTPServer.run, .{ &test_http_server.?, &wg });-- test_ws_server = TestWSServer.init();- test_ws_server_thread = try std.Thread.spawn(.{}, TestWSServer.run, .{ &test_ws_server.?, &wg });-- // need to wait for the servers to be listening, else tests will fail because- // they aren't able to connect.wg.wait();-- try routeTestPorts();}-// Fixtures address the test servers by fixed ports, but each test process binds-// ephemeral ones so that several can run at once.+/// Fixtures address the test servers by fixed ports, but each test process+/// binds ephemeral ones so that several can run at once.fn routeTestPorts() !void {- const http_port = test_http_server.?.port;- const ws_port = test_ws_server.?.port;- const routes = [_]struct { []const u8, u16, u16 }{- .{ "127.0.0.1", 9582, http_port },- .{ "localhost", 9582, http_port },- .{ "127.0.0.1", 9584, ws_port },- .{ "localhost", 9584, ws_port },+ const routes = [_]struct { u16, u16 }{+ .{ 9582, test_http_server.?.listener.?.socket.address.getPort() },+ .{ 9584, test_ws_server.?.port },};var list: ?*libcurl.CurlSList = null;errdefer libcurl.curl_slist_free_all(list);for (routes) |route| {- const host, const port, const real_port = route;- const entry = try arena_allocator.printSentinel("{s}:{d}:127.0.0.1:{d}", .{ host, port, real_port }, 0);+ const port, const real_port = route;+ // an empty host matches any, so both 127.0.0.1 and localhost+ const entry = try arena_allocator.printSentinel(":{d}:127.0.0.1:{d}", .{ port, real_port }, 0);list = libcurl.curl_slist_append(list, entry) orelse return error.OutOfMemory;}http.test_connect_to = list;@@ -651,10 +659,7 @@ fn serveCDP(wg: *lp.WaitGroup) !void {return err;};- var bound: std.posix.sockaddr.storage = undefined;- var bound_len: std.posix.socklen_t = @sizeOf(std.posix.sockaddr.storage);- try sys_net.getsockname(test_cdp_server.?.listener, @ptrCast(&bound), &bound_len);- test_cdp_port = sys_net.addressFromSockaddr(@ptrCast(&bound)).getPort();+ test_cdp_port = (try sys_net.boundAddress(test_cdp_server.?.listener)).getPort();test_cdp_server.?.protocols = .{ .cdp = true, .webdriver = true };wg.finish();