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 {...@@ -1773,25 +1773,41 @@ fn testImportingDataDynamic(b: *Build, opts: Options) *Step {
1773 .use_llvm = true,1773 .use_llvm = true,
1774 }, .{1774 }, .{
1775 .name = "a",1775 .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 ,
1777 });1781 });
1782 dso.linkLibC();
17781783
1779 const main = addExecutable(b, opts, .{1784 const main = addExecutable(b, opts, .{
1780 .name = "main",1785 .name = "main",
1781 .zig_source_bytes =1786 .zig_source_bytes =
1787 \\const std = @import("std");
1782 \\extern var foo: i32;1788 \\extern var foo: i32;
1789 \\extern fn printFoo() void;
1783 \\pub fn main() void {1790 \\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();
1785 \\}1796 \\}
1786 ,1797 ,
1787 .strip = true, // TODO temp hack1798 .strip = true, // TODO temp hack
1788 });1799 });
1789 main.pie = true;1800 main.pie = true;
1790 main.linkLibrary(dso);1801 main.linkLibrary(dso);
1791 main.linkLibC();
17921802
1793 const run = addRunArtifact(main);1803 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 );
1795 test_step.dependOn(&run.step);1811 test_step.dependOn(&run.step);
17961812
1797 return test_step;1813 return test_step;