authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-05-22 12:11:29+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-05-23 12:04:17+02:00
log03d0a683566216cdb0896b10900a543bc9c163c1
tree5337b1eebc58c7b4717f8a17315ea9ae82ad965e
parent28d08dd8a679c009aef35070d3991cf38618938e

test/link/macho: clean up merge literals tests on aarch64


1 files changed, 22 insertions(+), 37 deletions(-)

test/link/macho.zig+22-37
......@@ -38,8 +38,8 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
3838 macho_step.dependOn(testLayout(b, .{ .target = default_target }));
3939 macho_step.dependOn(testLinkingStaticLib(b, .{ .target = default_target }));
4040 macho_step.dependOn(testLinksection(b, .{ .target = default_target }));
41 macho_step.dependOn(testMergeLiterals(b, .{ .target = aarch64_target }));
42 macho_step.dependOn(testMergeLiterals2(b, .{ .target = aarch64_target }));
41 macho_step.dependOn(testMergeLiteralsArm64(b, .{ .target = aarch64_target }));
42 macho_step.dependOn(testMergeLiteralsArm642(b, .{ .target = aarch64_target }));
4343 macho_step.dependOn(testMhExecuteHeader(b, .{ .target = default_target }));
4444 macho_step.dependOn(testNoDeadStrip(b, .{ .target = default_target }));
4545 macho_step.dependOn(testNoExportsDylib(b, .{ .target = default_target }));
......@@ -917,7 +917,7 @@ fn testLinksection(b: *Build, opts: Options) *Step {
917917 return test_step;
918918}
919919
920fn testMergeLiterals(b: *Build, opts: Options) *Step {
920fn testMergeLiteralsArm64(b: *Build, opts: Options) *Step {
921921 const test_step = addTestStep(b, "merge-literals", opts);
922922
923923 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
......@@ -988,22 +988,27 @@ fn testMergeLiterals(b: *Build, opts: Options) *Step {
988988 \\}
989989 });
990990
991 const runWithChecks = struct {
992 fn runWithChecks(step: *Step, exe: *Compile) void {
993 const run = addRunArtifact(exe);
994 run.expectStdOutEqual("hello, hello, world, 1.234500, 1.234500");
995 step.dependOn(&run.step);
996
997 const check = exe.checkObject();
998 check.dumpSection("__TEXT,__const");
999 check.checkContains("\x8d\x97n\x12\x83\xc0\xf3?");
1000 check.dumpSection("__TEXT,__cstring");
1001 check.checkContains("hello\x00world\x00%s, %s, %s, %f, %f\x00");
1002 step.dependOn(&check.step);
1003 }
1004 }.runWithChecks;
1005
9911006 {
9921007 const exe = addExecutable(b, opts, .{ .name = "main1" });
9931008 exe.addObject(a_o);
9941009 exe.addObject(b_o);
9951010 exe.addObject(main_o);
996
997 const run = addRunArtifact(exe);
998 run.expectStdOutEqual("hello, hello, world, 1.234500, 1.234500");
999 test_step.dependOn(&run.step);
1000
1001 const check = exe.checkObject();
1002 check.dumpSection("__TEXT,__const");
1003 check.checkContains("\x8d\x97n\x12\x83\xc0\xf3?");
1004 check.dumpSection("__TEXT,__cstring");
1005 check.checkContains("hello\x00world\x00%s, %s, %s, %f, %f\x00");
1006 test_step.dependOn(&check.step);
1011 runWithChecks(test_step, exe);
10071012 }
10081013
10091014 {
......@@ -1011,17 +1016,7 @@ fn testMergeLiterals(b: *Build, opts: Options) *Step {
10111016 exe.addObject(b_o);
10121017 exe.addObject(a_o);
10131018 exe.addObject(main_o);
1014
1015 const run = addRunArtifact(exe);
1016 run.expectStdOutEqual("hello, hello, world, 1.234500, 1.234500");
1017 test_step.dependOn(&run.step);
1018
1019 const check = exe.checkObject();
1020 check.dumpSection("__TEXT,__const");
1021 check.checkContains("\x8d\x97n\x12\x83\xc0\xf3?");
1022 check.dumpSection("__TEXT,__cstring");
1023 check.checkContains("hello\x00world\x00%s, %s, %s, %f, %f\x00");
1024 test_step.dependOn(&check.step);
1019 runWithChecks(test_step, exe);
10251020 }
10261021
10271022 {
......@@ -1032,17 +1027,7 @@ fn testMergeLiterals(b: *Build, opts: Options) *Step {
10321027
10331028 const exe = addExecutable(b, opts, .{ .name = "main3" });
10341029 exe.addObject(c_o);
1035
1036 const run = addRunArtifact(exe);
1037 run.expectStdOutEqual("hello, hello, world, 1.234500, 1.234500");
1038 test_step.dependOn(&run.step);
1039
1040 const check = exe.checkObject();
1041 check.dumpSection("__TEXT,__const");
1042 check.checkContains("\x8d\x97n\x12\x83\xc0\xf3?");
1043 check.dumpSection("__TEXT,__cstring");
1044 check.checkContains("hello\x00world\x00%s, %s, %s, %f, %f\x00");
1045 test_step.dependOn(&check.step);
1030 runWithChecks(test_step, exe);
10461031 }
10471032
10481033 return test_step;
......@@ -1052,7 +1037,7 @@ fn testMergeLiterals(b: *Build, opts: Options) *Step {
10521037/// However, this is by design as we want to test that the linker does not panic when linking it
10531038/// which is also the case for the system linker and lld - linking succeeds, runtime segfaults.
10541039/// It should also be mentioned that runtime segfault is not due to the linker but faulty input asm.
1055fn testMergeLiterals2(b: *Build, opts: Options) *Step {
1040fn testMergeLiteralsArm642(b: *Build, opts: Options) *Step {
10561041 const test_step = addTestStep(b, "merge-literals-2", opts);
10571042
10581043 const a_o = addObject(b, opts, .{ .name = "a", .asm_source_bytes =