authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-13 23:32:41+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:39+01:00
log5142d92c514bc190224c30439c09b75169e0799a
tree6816feb898d9a19d5f5fdf62644280dfcb39620a
parent0cc4dc615b536eb5e927558f1391060ecf97b0ea

test/link/macho: test hello world in C


1 files changed, 25 insertions(+), 0 deletions(-)

test/link/macho.zig+25
...@@ -10,6 +10,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {...@@ -10,6 +10,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
1010
11 macho_step.dependOn(testDeadStrip(b, .{ .target = default_target }));11 macho_step.dependOn(testDeadStrip(b, .{ .target = default_target }));
12 macho_step.dependOn(testEntryPointDylib(b, .{ .target = default_target }));12 macho_step.dependOn(testEntryPointDylib(b, .{ .target = default_target }));
13 macho_step.dependOn(testHelloC(b, .{ .target = default_target }));
13 macho_step.dependOn(testHelloZig(b, .{ .target = default_target }));14 macho_step.dependOn(testHelloZig(b, .{ .target = default_target }));
14 macho_step.dependOn(testLargeBss(b, .{ .target = default_target }));15 macho_step.dependOn(testLargeBss(b, .{ .target = default_target }));
15 macho_step.dependOn(testMhExecuteHeader(b, .{ .target = default_target }));16 macho_step.dependOn(testMhExecuteHeader(b, .{ .target = default_target }));
...@@ -164,6 +165,30 @@ fn testEntryPointDylib(b: *Build, opts: Options) *Step {...@@ -164,6 +165,30 @@ fn testEntryPointDylib(b: *Build, opts: Options) *Step {
164 return test_step;165 return test_step;
165}166}
166167
168fn testHelloC(b: *Build, opts: Options) *Step {
169 const test_step = addTestStep(b, "macho-hello-c", opts);
170
171 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
172 \\#include <stdio.h>
173 \\int main() {
174 \\ printf("Hello world!\n");
175 \\ return 0;
176 \\}
177 });
178
179 const run = addRunArtifact(exe);
180 run.expectStdOutEqual("Hello world!\n");
181 test_step.dependOn(&run.step);
182
183 const check = exe.checkObject();
184 check.checkInHeaders();
185 check.checkExact("header");
186 check.checkContains("PIE");
187 test_step.dependOn(&check.step);
188
189 return test_step;
190}
191
167fn testHelloZig(b: *Build, opts: Options) *Step {192fn testHelloZig(b: *Build, opts: Options) *Step {
168 const test_step = addTestStep(b, "macho-hello-zig", opts);193 const test_step = addTestStep(b, "macho-hello-zig", opts);
169194