aboutsummaryrefslogtreecommitdiff
path: root/test/link/elf.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2024-08-15 21:47:34 +0200
committerJakub Konka <kubkon@jakubkonka.com>2024-08-15 21:47:34 +0200
commit9473d764498fbb4eef3e2bec42e44a3f93a5a56b (patch)
tree0a2c5800bd9ea315ae5cc8b06008a7a91b21fd8f /test/link/elf.zig
parent4d5bf0f09a29eeb0eb7f3602825f1a0095b8427e (diff)
downloadzig-9473d764498fbb4eef3e2bec42e44a3f93a5a56b.tar.gz
zig-9473d764498fbb4eef3e2bec42e44a3f93a5a56b.zip
test/elf: enhance testImportingDataDynamic
Diffstat (limited to 'test/link/elf.zig')
-rw-r--r--test/link/elf.zig24
1 files changed, 20 insertions, 4 deletions
diff --git a/test/link/elf.zig b/test/link/elf.zig
index 71b722a9f9..5539638ba7 100644
--- a/test/link/elf.zig
+++ b/test/link/elf.zig
@@ -1773,25 +1773,41 @@ fn testImportingDataDynamic(b: *Build, opts: Options) *Step {
.use_llvm = true,
}, .{
.name = "a",
- .c_source_bytes = "int foo = 42;",
+ .c_source_bytes =
+ \\#include <stdio.h>
+ \\int foo = 42;
+ \\void printFoo() { fprintf(stderr, "lib foo=%d\n", foo); }
+ ,
});
+ dso.linkLibC();
const main = addExecutable(b, opts, .{
.name = "main",
.zig_source_bytes =
+ \\const std = @import("std");
\\extern var foo: i32;
+ \\extern fn printFoo() void;
\\pub fn main() void {
- \\ @import("std").debug.print("{d}\n", .{foo});
+ \\ std.debug.print("exe foo={d}\n", .{foo});
+ \\ printFoo();
+ \\ foo += 1;
+ \\ std.debug.print("exe foo={d}\n", .{foo});
+ \\ printFoo();
\\}
,
.strip = true, // TODO temp hack
});
main.pie = true;
main.linkLibrary(dso);
- main.linkLibC();
const run = addRunArtifact(main);
- run.expectStdErrEqual("42\n");
+ run.expectStdErrEqual(
+ \\exe foo=42
+ \\lib foo=42
+ \\exe foo=43
+ \\lib foo=43
+ \\
+ );
test_step.dependOn(&run.step);
return test_step;