authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-06-20 17:29:00+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-06-20 17:59:17+02:00
log6e56a8df20395749b21b3857952dae1c227aacf1
treea18fdda93dd30bc018fef441a662e1e91dd1951e
parent38edef35bfcba5789ea50adc7c76dec504079812

link-tests: CheckFileStep to do grep test on the binary


3 files changed, 13 insertions(+), 5 deletions(-)

test/link.zig+4-4
...@@ -7,10 +7,6 @@ pub fn addCases(cases: *tests.StandaloneContext) void {...@@ -7,10 +7,6 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
7 .build_modes = false, // we only guarantee zerofill for undefined in Debug7 .build_modes = false, // we only guarantee zerofill for undefined in Debug
8 });8 });
99
10 cases.addBuildFile("test/link/dylib/build.zig", .{
11 .build_modes = true,
12 });
13
14 cases.addBuildFile("test/link/common_symbols/build.zig", .{10 cases.addBuildFile("test/link/common_symbols/build.zig", .{
15 .build_modes = true,11 .build_modes = true,
16 });12 });
...@@ -32,6 +28,10 @@ pub fn addCases(cases: *tests.StandaloneContext) void {...@@ -32,6 +28,10 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
32 });28 });
3329
34 if (builtin.os.tag == .macos) {30 if (builtin.os.tag == .macos) {
31 cases.addBuildFile("test/link/dylib/build.zig", .{
32 .build_modes = true,
33 });
34
35 cases.addBuildFile("test/link/frameworks/build.zig", .{35 cases.addBuildFile("test/link/frameworks/build.zig", .{
36 .build_modes = true,36 .build_modes = true,
37 .requires_macos_sdk = true,37 .requires_macos_sdk = true,
test/link/dylib/build.zig+7
...@@ -24,6 +24,13 @@ pub fn build(b: *Builder) void {...@@ -24,6 +24,13 @@ pub fn build(b: *Builder) void {
24 run.cwd = b.pathFromRoot(".");24 run.cwd = b.pathFromRoot(".");
25 run.expectStdOutEqual("Hello world");25 run.expectStdOutEqual("Hello world");
2626
27 const exp_dylib = std.macho.createLoadDylibCommand(b.allocator, "@rpath/liba.dylib", 2, 0x10000, 0x10000) catch unreachable;
28 var buf = std.ArrayList(u8).init(b.allocator);
29 defer buf.deinit();
30 exp_dylib.write(buf.writer()) catch unreachable;
31 const check_file = std.build.CheckFileStep.create(b, exe.getOutputSource(), &[_][]const u8{buf.items});
32
27 test_step.dependOn(b.getInstallStep());33 test_step.dependOn(b.getInstallStep());
28 test_step.dependOn(&run.step);34 test_step.dependOn(&run.step);
35 test_step.dependOn(&check_file.step);
29}36}
test/tests.zig+2-1
...@@ -995,7 +995,8 @@ pub const StandaloneContext = struct {...@@ -995,7 +995,8 @@ pub const StandaloneContext = struct {
995 }995 }
996996
997 if (features.cross_targets and !self.target.isNative()) {997 if (features.cross_targets and !self.target.isNative()) {
998 const target_arg = fmt.allocPrint(b.allocator, "-Dtarget={s}", .{self.target.zigTriple(b.allocator) catch unreachable}) catch unreachable;998 const target_triple = self.target.zigTriple(b.allocator) catch unreachable;
999 const target_arg = fmt.allocPrint(b.allocator, "-Dtarget={s}", .{target_triple}) catch unreachable;
999 zig_args.append(target_arg) catch unreachable;1000 zig_args.append(target_arg) catch unreachable;
1000 }1001 }
10011002