authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-12 21:17:53+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:39+01:00
logee68f35bfe742220f3fdebe97548425bb5440da1
tree60b115b6102cadb1e78952cb46e359cfe6ae45f7
parentee7a027059d87c10533744920793bca0bdec9687

macho: fix section boundary symbols test


1 files changed, 16 insertions(+), 11 deletions(-)

test/link/macho.zig+16-11
......@@ -4,15 +4,15 @@
44pub fn testAll(b: *std.Build) *Step {
55 const macho_step = b.step("test-macho", "Run MachO tests");
66
7 macho_step.dependOn(testResolvingBoundarySymbols(b, .{
7 macho_step.dependOn(testSectionBoundarySymbols(b, .{
88 .target = b.resolveTargetQuery(.{ .os_tag = .macos }),
99 }));
1010
1111 return macho_step;
1212}
1313
14fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step {
15 const test_step = addTestStep(b, "macho-resolving-boundary-symbols", opts);
14fn testSectionBoundarySymbols(b: *std.Build, opts: Options) *Step {
15 const test_step = addTestStep(b, "macho-section-boundary-symbols", opts);
1616
1717 const obj1 = addObject(b, opts, .{
1818 .name = "obj1",
......@@ -25,10 +25,10 @@ fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step {
2525 .name = "main",
2626 .zig_source_bytes =
2727 \\const std = @import("std");
28 \\extern fn interop() [*:0]const u8;
28 \\extern fn interop() ?[*:0]const u8;
2929 \\pub fn main() !void {
3030 \\ std.debug.print("All your {s} are belong to us.\n", .{
31 \\ std.mem.span(interop()),
31 \\ if (interop()) |ptr| std.mem.span(ptr) else "(null)",
3232 \\ });
3333 \\}
3434 ,
......@@ -57,7 +57,7 @@ fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step {
5757
5858 const check = exe.checkObject();
5959 check.checkInSymtab();
60 check.checkNotPresent("section$start$__DATA_CONST$__message_ptr");
60 check.checkNotPresent("external section$start$__DATA_CONST$__message_ptr");
6161 test_step.dependOn(&check.step);
6262 }
6363
......@@ -65,7 +65,7 @@ fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step {
6565 const obj3 = addObject(b, opts, .{
6666 .name = "obj3",
6767 .cpp_source_bytes =
68 \\extern const char* message_pointer __asm("section$start$__DATA$__message_ptr");
68 \\extern const char* message_pointer __asm("section$start$__DATA_CONST$__not_present");
6969 \\extern "C" const char* interop() {
7070 \\ return message_pointer;
7171 \\}
......@@ -77,10 +77,15 @@ fn testResolvingBoundarySymbols(b: *std.Build, opts: Options) *Step {
7777 exe.addObject(obj3);
7878 exe.addObject(main_o);
7979
80 expectLinkErrors(exe, test_step, .{ .exact = &.{
81 "section not found: __DATA,__message_ptr",
82 "note: while resolving section$start$__DATA$__message_ptr",
83 } });
80 const run = b.addRunArtifact(exe);
81 run.skip_foreign_checks = true;
82 run.expectStdErrEqual("All your (null) are belong to us.\n");
83 test_step.dependOn(&run.step);
84
85 const check = exe.checkObject();
86 check.checkInSymtab();
87 check.checkNotPresent("external section$start$__DATA_CONST$__not_present");
88 test_step.dependOn(&check.step);
8489 }
8590
8691 return test_step;