authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-15 08:58:44+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:40+01:00
loga454ba79083128e3172d2ca14fced9ec4a3763b1
treef8358a2b5aaa3298df739da8356acc501d89a209
parent8105390fff82f372645b01dbfe89f7972ba4e49d

test/link/macho: upgrade dylib test


2 files changed, 38 insertions(+), 4 deletions(-)

test/link.zig-4
......@@ -107,10 +107,6 @@ pub const cases = [_]Case{
107107 .build_root = "test/link/macho/bugs/16628",
108108 .import = @import("link/macho/bugs/16628/build.zig"),
109109 },
110 .{
111 .build_root = "test/link/macho/dylib",
112 .import = @import("link/macho/dylib/build.zig"),
113 },
114110 .{
115111 .build_root = "test/link/macho/empty",
116112 .import = @import("link/macho/empty/build.zig"),
test/link/macho.zig+38
......@@ -35,6 +35,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
3535
3636 // Tests requiring symlinks when tested on Windows
3737 if (build_opts.has_symlinks_windows) {
38 macho_step.dependOn(testDylib(b, .{ .target = default_target }));
3839 macho_step.dependOn(testNeededLibrary(b, .{ .target = default_target }));
3940 macho_step.dependOn(testWeakLibrary(b, .{ .target = default_target }));
4041 macho_step.dependOn(testTls(b, .{ .target = default_target }));
......@@ -182,6 +183,43 @@ fn testDeadStripDylibs(b: *Build, opts: Options) *Step {
182183 return test_step;
183184}
184185
186fn testDylib(b: *Build, opts: Options) *Step {
187 const test_step = addTestStep(b, "macho-dylib", opts);
188
189 const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes =
190 \\#include<stdio.h>
191 \\char world[] = "world";
192 \\char* hello() {
193 \\ return "Hello";
194 \\}
195 });
196
197 const check = dylib.checkObject();
198 check.checkInHeaders();
199 check.checkExact("header");
200 check.checkNotPresent("PIE");
201 test_step.dependOn(&check.step);
202
203 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
204 \\#include<stdio.h>
205 \\char* hello();
206 \\extern char world[];
207 \\int main() {
208 \\ printf("%s %s", hello(), world);
209 \\ return 0;
210 \\}
211 });
212 exe.root_module.linkSystemLibrary("a", .{});
213 exe.addLibraryPath(dylib.getEmittedBinDirectory());
214 exe.addRPath(dylib.getEmittedBinDirectory());
215
216 const run = addRunArtifact(exe);
217 run.expectStdOutEqual("Hello world");
218 test_step.dependOn(&run.step);
219
220 return test_step;
221}
222
185223fn testEntryPointDylib(b: *Build, opts: Options) *Step {
186224 const test_step = addTestStep(b, "macho-entry-point-dylib", opts);
187225