authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-08-15 21:47:34+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-08-15 21:47:34+02:00
log9473d764498fbb4eef3e2bec42e44a3f93a5a56b
tree0a2c5800bd9ea315ae5cc8b06008a7a91b21fd8f
parent4d5bf0f09a29eeb0eb7f3602825f1a0095b8427e

test/elf: enhance testImportingDataDynamic


1 files changed, 20 insertions(+), 4 deletions(-)

test/link/elf.zig+20-4
......@@ -1773,25 +1773,41 @@ fn testImportingDataDynamic(b: *Build, opts: Options) *Step {
17731773 .use_llvm = true,
17741774 }, .{
17751775 .name = "a",
1776 .c_source_bytes = "int foo = 42;",
1776 .c_source_bytes =
1777 \\#include <stdio.h>
1778 \\int foo = 42;
1779 \\void printFoo() { fprintf(stderr, "lib foo=%d\n", foo); }
1780 ,
17771781 });
1782 dso.linkLibC();
17781783
17791784 const main = addExecutable(b, opts, .{
17801785 .name = "main",
17811786 .zig_source_bytes =
1787 \\const std = @import("std");
17821788 \\extern var foo: i32;
1789 \\extern fn printFoo() void;
17831790 \\pub fn main() void {
1784 \\ @import("std").debug.print("{d}\n", .{foo});
1791 \\ std.debug.print("exe foo={d}\n", .{foo});
1792 \\ printFoo();
1793 \\ foo += 1;
1794 \\ std.debug.print("exe foo={d}\n", .{foo});
1795 \\ printFoo();
17851796 \\}
17861797 ,
17871798 .strip = true, // TODO temp hack
17881799 });
17891800 main.pie = true;
17901801 main.linkLibrary(dso);
1791 main.linkLibC();
17921802
17931803 const run = addRunArtifact(main);
1794 run.expectStdErrEqual("42\n");
1804 run.expectStdErrEqual(
1805 \\exe foo=42
1806 \\lib foo=42
1807 \\exe foo=43
1808 \\lib foo=43
1809 \\
1810 );
17951811 test_step.dependOn(&run.step);
17961812
17971813 return test_step;