mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 21:38:33 +00:00
test/link/macho: upgrade dead_strip_dylibs test
This commit is contained in:
parent
b038bcb93b
commit
181e476915
@ -107,10 +107,6 @@ pub const cases = [_]Case{
|
||||
.build_root = "test/link/macho/bugs/16628",
|
||||
.import = @import("link/macho/bugs/16628/build.zig"),
|
||||
},
|
||||
.{
|
||||
.build_root = "test/link/macho/dead_strip_dylibs",
|
||||
.import = @import("link/macho/dead_strip_dylibs/build.zig"),
|
||||
},
|
||||
.{
|
||||
.build_root = "test/link/macho/dylib",
|
||||
.import = @import("link/macho/dylib/build.zig"),
|
||||
|
||||
@ -42,6 +42,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
|
||||
|
||||
// Tests requiring presence of macOS SDK in system path
|
||||
if (build_opts.has_macos_sdk) {
|
||||
macho_step.dependOn(testDeadStripDylibs(b, .{ .target = b.host }));
|
||||
macho_step.dependOn(testHeaderpad(b, .{ .target = b.host }));
|
||||
macho_step.dependOn(testNeededFramework(b, .{ .target = b.host }));
|
||||
macho_step.dependOn(testWeakFramework(b, .{ .target = b.host }));
|
||||
@ -132,6 +133,55 @@ fn testDeadStrip(b: *Build, opts: Options) *Step {
|
||||
return test_step;
|
||||
}
|
||||
|
||||
fn testDeadStripDylibs(b: *Build, opts: Options) *Step {
|
||||
const test_step = addTestStep(b, "macho-dead-strip-dylibs", opts);
|
||||
|
||||
const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes =
|
||||
\\#include <objc/runtime.h>
|
||||
\\int main() {
|
||||
\\ if (objc_getClass("NSObject") == 0) {
|
||||
\\ return -1;
|
||||
\\ }
|
||||
\\ if (objc_getClass("NSApplication") == 0) {
|
||||
\\ return -2;
|
||||
\\ }
|
||||
\\ return 0;
|
||||
\\}
|
||||
});
|
||||
|
||||
{
|
||||
const exe = addExecutable(b, opts, .{ .name = "main1" });
|
||||
exe.addObject(main_o);
|
||||
exe.root_module.linkFramework("Cocoa", .{});
|
||||
|
||||
const check = exe.checkObject();
|
||||
check.checkInHeaders();
|
||||
check.checkExact("cmd LOAD_DYLIB");
|
||||
check.checkContains("Cocoa");
|
||||
check.checkInHeaders();
|
||||
check.checkExact("cmd LOAD_DYLIB");
|
||||
check.checkContains("libobjc");
|
||||
test_step.dependOn(&check.step);
|
||||
|
||||
const run = addRunArtifact(exe);
|
||||
run.expectExitCode(0);
|
||||
test_step.dependOn(&run.step);
|
||||
}
|
||||
|
||||
{
|
||||
const exe = addExecutable(b, opts, .{ .name = "main2" });
|
||||
exe.addObject(main_o);
|
||||
exe.root_module.linkFramework("Cocoa", .{});
|
||||
exe.dead_strip_dylibs = true;
|
||||
|
||||
const run = addRunArtifact(exe);
|
||||
run.expectExitCode(@as(u8, @bitCast(@as(i8, -2))));
|
||||
test_step.dependOn(&run.step);
|
||||
}
|
||||
|
||||
return test_step;
|
||||
}
|
||||
|
||||
fn testEntryPointDylib(b: *Build, opts: Options) *Step {
|
||||
const test_step = addTestStep(b, "macho-entry-point-dylib", opts);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user