From 1ea2d5692d5e0ed5adf1a398f43a442b22c7563d Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Mon, 29 Dec 2025 21:02:11 -0500 Subject: [PATCH] openbsd: init Io.Threaded.argv0 for tests Some tests (eg. std.process.openExecutable) require argv0 for OpenBSD, otherwise error.OperationUnsupported is encountered. --- lib/compiler/test_runner.zig | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/compiler/test_runner.zig b/lib/compiler/test_runner.zig index da3da684d920bd9758406453a19eda086782b676..95e4b9503c10f43d5eddad5c6c44e200a0e460fa 100644 --- a/lib/compiler/test_runner.zig +++ b/lib/compiler/test_runner.zig @@ -66,13 +66,13 @@ pub fn main() void { } if (listen) { - return mainServer() catch @panic("internal test runner failure"); + return mainServer(args) catch @panic("internal test runner failure"); } else { - return mainTerminal(); + return mainTerminal(args); } } -fn mainServer() !void { +fn mainServer(args: []const [:0]const u8) !void { @disableInstrumentation(); var stdin_reader = Io.File.stdin().readerStreaming(runner_threaded_io, &stdin_buffer); var stdout_writer = Io.File.stdout().writerStreaming(runner_threaded_io, &stdout_buffer); @@ -131,7 +131,9 @@ fn mainServer() !void { .run_test => { testing.allocator_instance = .{}; - testing.io_instance = .init(testing.allocator, .{}); + testing.io_instance = .init(testing.allocator, .{ + .argv0 = if (@hasField(Io.Threaded.Argv0, "value")) .{ .value = args[0] } else .{}, + }); log_err_count = 0; const index = try server.receiveBody_u32(); const test_fn = builtin.test_functions[index]; @@ -215,7 +217,7 @@ fn mainServer() !void { } } -fn mainTerminal() void { +fn mainTerminal(args: []const [:0]const u8) void { @disableInstrumentation(); if (builtin.fuzz) @panic("fuzz test requires server"); @@ -233,7 +235,9 @@ fn mainTerminal() void { var leaks: usize = 0; for (test_fn_list, 0..) |test_fn, i| { testing.allocator_instance = .{}; - testing.io_instance = .init(testing.allocator, .{}); + testing.io_instance = .init(testing.allocator, .{ + .argv0 = if (@hasField(Io.Threaded.Argv0, "value")) .{ .value = args[0] } else .{}, + }); defer { testing.io_instance.deinit(); if (testing.allocator_instance.deinit() == .leak) leaks += 1; -- 2.54.0