test/link/macho: test hello world in Zig

This commit is contained in:
Jakub Konka 2024-01-13 19:15:56 +01:00
parent bf285c7e40
commit 0cc4dc615b

View File

@ -10,6 +10,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
macho_step.dependOn(testDeadStrip(b, .{ .target = default_target }));
macho_step.dependOn(testEntryPointDylib(b, .{ .target = default_target }));
macho_step.dependOn(testHelloZig(b, .{ .target = default_target }));
macho_step.dependOn(testLargeBss(b, .{ .target = default_target }));
macho_step.dependOn(testMhExecuteHeader(b, .{ .target = default_target }));
macho_step.dependOn(testSectionBoundarySymbols(b, .{ .target = default_target }));
@ -163,6 +164,23 @@ fn testEntryPointDylib(b: *Build, opts: Options) *Step {
return test_step;
}
fn testHelloZig(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "macho-hello-zig", opts);
const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
\\const std = @import("std");
\\pub fn main() void {
\\ std.io.getStdOut().writer().print("Hello world!\n", .{}) catch unreachable;
\\}
});
const run = addRunArtifact(exe);
run.expectStdOutEqual("Hello world!\n");
test_step.dependOn(&run.step);
return test_step;
}
fn testLargeBss(b: *Build, opts: Options) *Step {
const test_step = addTestStep(b, "macho-large-bss", opts);