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 {
77 .build_modes = false, // we only guarantee zerofill for undefined in Debug
88 });
99
10 cases.addBuildFile("test/link/dylib/build.zig", .{
11 .build_modes = true,
12 });
13
1410 cases.addBuildFile("test/link/common_symbols/build.zig", .{
1511 .build_modes = true,
1612 });
......@@ -32,6 +28,10 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
3228 });
3329
3430 if (builtin.os.tag == .macos) {
31 cases.addBuildFile("test/link/dylib/build.zig", .{
32 .build_modes = true,
33 });
34
3535 cases.addBuildFile("test/link/frameworks/build.zig", .{
3636 .build_modes = true,
3737 .requires_macos_sdk = true,
test/link/dylib/build.zig+7
......@@ -24,6 +24,13 @@ pub fn build(b: *Builder) void {
2424 run.cwd = b.pathFromRoot(".");
2525 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
2733 test_step.dependOn(b.getInstallStep());
2834 test_step.dependOn(&run.step);
35 test_step.dependOn(&check_file.step);
2936}
test/tests.zig+2-1
......@@ -995,7 +995,8 @@ pub const StandaloneContext = struct {
995995 }
996996
997997 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;
9991000 zig_args.append(target_arg) catch unreachable;
10001001 }
10011002