authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-05-24 22:43:23+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-05-24 22:43:23+02:00
log19f41d390f6761885c836be9c1a57efc8e81a606
tree2033b89fe69e7dab4722b5b02573ecd3df2bf071
parent8e52d54c25b1e7a4fd71593299a85493b2262bfe

test/link/macho: add symbol stabs smoke test


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

test/link/macho.zig+49
......@@ -51,6 +51,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
5151 macho_step.dependOn(testRelocatableZig(b, .{ .target = default_target }));
5252 macho_step.dependOn(testSectionBoundarySymbols(b, .{ .target = default_target }));
5353 macho_step.dependOn(testSegmentBoundarySymbols(b, .{ .target = default_target }));
54 macho_step.dependOn(testSymbolStabs(b, .{ .target = default_target }));
5455 macho_step.dependOn(testStackSize(b, .{ .target = default_target }));
5556 macho_step.dependOn(testTentative(b, .{ .target = default_target }));
5657 macho_step.dependOn(testThunks(b, .{ .target = aarch64_target }));
......@@ -1993,6 +1994,54 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {
19931994 return test_step;
19941995}
19951996
1997fn testSymbolStabs(b: *Build, opts: Options) *Step {
1998 const test_step = addTestStep(b, "symbol-stabs", opts);
1999
2000 const a_o = addObject(b, opts, .{ .name = "a", .c_source_bytes =
2001 \\int foo = 42;
2002 \\int getFoo() {
2003 \\ return foo;
2004 \\}
2005 });
2006
2007 const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
2008 \\int bar = 24;
2009 \\int getBar() {
2010 \\ return bar;
2011 \\}
2012 });
2013
2014 const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
2015 \\#include <stdio.h>
2016 \\extern int getFoo();
2017 \\extern int getBar();
2018 \\int main() {
2019 \\ printf("foo=%d,bar=%d", getFoo(), getBar());
2020 \\ return 0;
2021 \\}
2022 });
2023
2024 const exe = addExecutable(b, opts, .{ .name = "main" });
2025 exe.addObject(a_o);
2026 exe.addObject(b_o);
2027 exe.addObject(main_o);
2028
2029 const run = addRunArtifact(exe);
2030 run.expectStdOutEqual("foo=42,bar=24");
2031 test_step.dependOn(&run.step);
2032
2033 const check = exe.checkObject();
2034 check.checkInSymtab();
2035 check.checkContains("a.o"); // TODO we really should do a fuzzy search like OSO <ignore>/a.o
2036 check.checkInSymtab();
2037 check.checkContains("b.o");
2038 check.checkInSymtab();
2039 check.checkContains("main.o");
2040 test_step.dependOn(&check.step);
2041
2042 return test_step;
2043}
2044
19962045fn testStackSize(b: *Build, opts: Options) *Step {
19972046 const test_step = addTestStep(b, "stack-size", opts);
19982047