diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2024-04-20 23:02:23 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2024-04-20 23:36:42 +0200 |
| commit | 342235e5eb30426cf8bba0ad76e14e21fac18e79 (patch) | |
| tree | 15feea87308850df8a7e1464bf7d79c0fd36a188 | |
| parent | 4931a291f86410d5c43dd9471d23b7e890f91246 (diff) | |
| download | zig-342235e5eb30426cf8bba0ad76e14e21fac18e79.tar.gz zig-342235e5eb30426cf8bba0ad76e14e21fac18e79.zip | |
test/link/elf: enhance merge strings tests
| -rw-r--r-- | test/link/elf.zig | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/test/link/elf.zig b/test/link/elf.zig index 798496de6b..6d47df10e4 100644 --- a/test/link/elf.zig +++ b/test/link/elf.zig @@ -2328,7 +2328,7 @@ fn testMergeStrings(b: *Build, opts: Options) *Step { fn testMergeStrings2(b: *Build, opts: Options) *Step { const test_step = addTestStep(b, "merge-strings2", opts); - const obj1 = addObject(b, opts, .{ .name = "a.o", .zig_source_bytes = + const obj1 = addObject(b, opts, .{ .name = "a", .zig_source_bytes = \\const std = @import("std"); \\export fn foo() void { \\ var arr: [5:0]u16 = [_:0]u16{ 1, 2, 3, 4, 5 }; @@ -2337,7 +2337,7 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step { \\} }); - const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes = + const obj2 = addObject(b, opts, .{ .name = "b", .zig_source_bytes = \\const std = @import("std"); \\extern fn foo() void; \\pub fn main() void { @@ -2347,18 +2347,43 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step { \\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable; \\} }); - exe.addObject(obj1); - const run = addRunArtifact(exe); - run.expectExitCode(0); - test_step.dependOn(&run.step); + { + const exe = addExecutable(b, opts, .{ .name = "main1" }); + exe.addObject(obj1); + exe.addObject(obj2); - const check = exe.checkObject(); - check.dumpSection(".rodata.str"); - check.checkContains("\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x00\x00"); - check.dumpSection(".rodata.str"); - check.checkContains("\x05\x00\x04\x00\x03\x00\x02\x00\x01\x00\x00\x00"); - test_step.dependOn(&check.step); + const run = addRunArtifact(exe); + run.expectExitCode(0); + test_step.dependOn(&run.step); + + const check = exe.checkObject(); + check.dumpSection(".rodata.str"); + check.checkContains("\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x00\x00"); + check.dumpSection(".rodata.str"); + check.checkContains("\x05\x00\x04\x00\x03\x00\x02\x00\x01\x00\x00\x00"); + test_step.dependOn(&check.step); + } + + { + const obj3 = addObject(b, opts, .{ .name = "c" }); + obj3.addObject(obj1); + obj3.addObject(obj2); + + const exe = addExecutable(b, opts, .{ .name = "main2" }); + exe.addObject(obj3); + + const run = addRunArtifact(exe); + run.expectExitCode(0); + test_step.dependOn(&run.step); + + const check = exe.checkObject(); + check.dumpSection(".rodata.str"); + check.checkContains("\x01\x00\x02\x00\x03\x00\x04\x00\x05\x00\x00\x00"); + check.dumpSection(".rodata.str"); + check.checkContains("\x05\x00\x04\x00\x03\x00\x02\x00\x01\x00\x00\x00"); + test_step.dependOn(&check.step); + } return test_step; } |
