authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-01-11 17:25:02+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-01-14 16:26:50+02:00
log474848ac0b6cd026502d85f0f77f0474516e887b
tree3fd758e3e38efb6abe47c29619d12f8dc67a999c
parent3ab43988c1cc5e22c84faccd1816df6e8094d9a3

also run C ABI tests with -OReleaseFast


3 files changed, 30 insertions(+), 6 deletions(-)

build.zig+1-1
...@@ -439,7 +439,7 @@ pub fn build(b: *Builder) !void {...@@ -439,7 +439,7 @@ pub fn build(b: *Builder) !void {
439 b.enable_wine,439 b.enable_wine,
440 enable_symlinks_windows,440 enable_symlinks_windows,
441 ));441 ));
442 test_step.dependOn(tests.addCAbiTests(b, skip_non_native));442 test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release));
443 test_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, skip_stage2_tests, enable_symlinks_windows));443 test_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, skip_stage2_tests, enable_symlinks_windows));
444 test_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));444 test_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));
445 test_step.dependOn(tests.addCliTests(b, test_filter, modes));445 test_step.dependOn(tests.addCliTests(b, test_filter, modes));
test/c_abi/main.zig+21-1
...@@ -4,7 +4,7 @@...@@ -4,7 +4,7 @@
4//! To run all the tests on the tier 1 architecture you can use:4//! To run all the tests on the tier 1 architecture you can use:
5//! zig build test-c-abi -fqemu5//! zig build test-c-abi -fqemu
6//! To run the tests on a specific architecture:6//! To run the tests on a specific architecture:
7//! zig test -fno-stage1 -lc main.zig cfuncs.c -target mips-linux --test-cmd qemu-mips --test-cmd-bin7//! zig test -lc main.zig cfuncs.c -target mips-linux --test-cmd qemu-mips --test-cmd-bin
8const std = @import("std");8const std = @import("std");
9const builtin = @import("builtin");9const builtin = @import("builtin");
10const print = std.debug.print;10const print = std.debug.print;
...@@ -764,6 +764,7 @@ extern fn c_float_array_struct(FloatArrayStruct) void;...@@ -764,6 +764,7 @@ extern fn c_float_array_struct(FloatArrayStruct) void;
764extern fn c_ret_float_array_struct() FloatArrayStruct;764extern fn c_ret_float_array_struct() FloatArrayStruct;
765765
766test "Float array like struct" {766test "Float array like struct" {
767 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
767 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;768 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
768 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;769 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
769770
...@@ -824,7 +825,9 @@ extern fn c_big_vec(BigVec) void;...@@ -824,7 +825,9 @@ extern fn c_big_vec(BigVec) void;
824extern fn c_ret_big_vec() BigVec;825extern fn c_ret_big_vec() BigVec;
825826
826test "big simd vector" {827test "big simd vector" {
828 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
827 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;829 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
830 if (builtin.cpu.arch == .x86_64 and builtin.os.tag == .macos and builtin.mode != .Debug) return error.SkipZigTest;
828831
829 c_big_vec(.{ 1, 2, 3, 4, 5, 6, 7, 8 });832 c_big_vec(.{ 1, 2, 3, 4, 5, 6, 7, 8 });
830833
...@@ -875,6 +878,8 @@ test "DC: Zig passes to C" {...@@ -875,6 +878,8 @@ test "DC: Zig passes to C" {
875 try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 }));878 try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 }));
876}879}
877test "DC: Zig returns to C" {880test "DC: Zig returns to C" {
881 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
882 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
878 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;883 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
879 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;884 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
880 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;885 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
...@@ -888,6 +893,8 @@ test "DC: C passes to Zig" {...@@ -888,6 +893,8 @@ test "DC: C passes to Zig" {
888 try expectOk(c_send_DC());893 try expectOk(c_send_DC());
889}894}
890test "DC: C returns to Zig" {895test "DC: C returns to Zig" {
896 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
897 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
891 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;898 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
892 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;899 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
893 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;900 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
...@@ -920,13 +927,17 @@ test "CFF: Zig passes to C" {...@@ -920,13 +927,17 @@ test "CFF: Zig passes to C" {
920 try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }));927 try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }));
921}928}
922test "CFF: Zig returns to C" {929test "CFF: Zig returns to C" {
930 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
923 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;931 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
924 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;932 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
925 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;933 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
926 try expectOk(c_assert_ret_CFF());934 try expectOk(c_assert_ret_CFF());
927}935}
928test "CFF: C passes to Zig" {936test "CFF: C passes to Zig" {
937 if (builtin.cpu.arch == .x86_64 and builtin.mode != .Debug) return error.SkipZigTest;
929 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;938 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
939 if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest;
940 if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest;
930 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;941 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
931 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;942 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
932 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;943 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
...@@ -934,6 +945,10 @@ test "CFF: C passes to Zig" {...@@ -934,6 +945,10 @@ test "CFF: C passes to Zig" {
934 try expectOk(c_send_CFF());945 try expectOk(c_send_CFF());
935}946}
936test "CFF: C returns to Zig" {947test "CFF: C returns to Zig" {
948 if (builtin.cpu.arch == .x86_64 and builtin.mode != .Debug) return error.SkipZigTest;
949 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
950 if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest;
951 if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest;
937 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;952 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
938 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;953 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
939 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;954 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
...@@ -967,6 +982,7 @@ test "PD: Zig passes to C" {...@@ -967,6 +982,7 @@ test "PD: Zig passes to C" {
967}982}
968test "PD: Zig returns to C" {983test "PD: Zig returns to C" {
969 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;984 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
985 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
970 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;986 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
971 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;987 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
972 try expectOk(c_assert_ret_PD());988 try expectOk(c_assert_ret_PD());
...@@ -980,6 +996,7 @@ test "PD: C passes to Zig" {...@@ -980,6 +996,7 @@ test "PD: C passes to Zig" {
980}996}
981test "PD: C returns to Zig" {997test "PD: C returns to Zig" {
982 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;998 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
999 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
983 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;1000 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
984 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;1001 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
985 try expectEqual(c_ret_PD(), .{ .v1 = null, .v2 = 0.5 });1002 try expectEqual(c_ret_PD(), .{ .v1 = null, .v2 = 0.5 });
...@@ -1014,6 +1031,7 @@ extern fn c_modify_by_ref_param(ByRef) ByRef;...@@ -1014,6 +1031,7 @@ extern fn c_modify_by_ref_param(ByRef) ByRef;
10141031
1015test "C function modifies by ref param" {1032test "C function modifies by ref param" {
1016 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;1033 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
1034 if (builtin.cpu.arch == .x86_64 and builtin.os.tag == .windows and builtin.mode != .Debug) return error.SkipZigTest;
10171035
1018 const res = c_modify_by_ref_param(.{ .val = 1, .arr = undefined });1036 const res = c_modify_by_ref_param(.{ .val = 1, .arr = undefined });
1019 try expect(res.val == 42);1037 try expect(res.val == 42);
...@@ -1034,6 +1052,8 @@ const ByVal = extern struct {...@@ -1034,6 +1052,8 @@ const ByVal = extern struct {
10341052
1035extern fn c_func_ptr_byval(*anyopaque, *anyopaque, ByVal, c_ulong, *anyopaque, c_ulong) void;1053extern fn c_func_ptr_byval(*anyopaque, *anyopaque, ByVal, c_ulong, *anyopaque, c_ulong) void;
1036test "C function that takes byval struct called via function pointer" {1054test "C function that takes byval struct called via function pointer" {
1055 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
1056 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
1037 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;1057 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
10381058
1039 var fn_ptr = &c_func_ptr_byval;1059 var fn_ptr = &c_func_ptr_byval;
test/tests.zig+8-4
...@@ -1323,10 +1323,12 @@ const c_abi_targets = [_]CrossTarget{...@@ -1323,10 +1323,12 @@ const c_abi_targets = [_]CrossTarget{
1323 },1323 },
1324};1324};
13251325
1326pub fn addCAbiTests(b: *build.Builder, skip_non_native: bool) *build.Step {1326pub fn addCAbiTests(b: *build.Builder, skip_non_native: bool, skip_release: bool) *build.Step {
1327 const step = b.step("test-c-abi", "Run the C ABI tests");1327 const step = b.step("test-c-abi", "Run the C ABI tests");
13281328
1329 for (c_abi_targets) |c_abi_target| {1329 const modes: [2]Mode = .{ .Debug, .ReleaseFast };
1330
1331 for (modes[0 .. @as(u8, 1) + @boolToInt(!skip_release)]) |mode| for (c_abi_targets) |c_abi_target| {
1330 if (skip_non_native and !c_abi_target.isNative())1332 if (skip_non_native and !c_abi_target.isNative())
1331 continue;1333 continue;
13321334
...@@ -1339,14 +1341,16 @@ pub fn addCAbiTests(b: *build.Builder, skip_non_native: bool) *build.Step {...@@ -1339,14 +1341,16 @@ pub fn addCAbiTests(b: *build.Builder, skip_non_native: bool) *build.Step {
1339 }1341 }
1340 test_step.linkLibC();1342 test_step.linkLibC();
1341 test_step.addCSourceFile("test/c_abi/cfuncs.c", &.{"-std=c99"});1343 test_step.addCSourceFile("test/c_abi/cfuncs.c", &.{"-std=c99"});
1344 test_step.setBuildMode(mode);
13421345
1343 const triple_prefix = c_abi_target.zigTriple(b.allocator) catch unreachable;1346 const triple_prefix = c_abi_target.zigTriple(b.allocator) catch unreachable;
1344 test_step.setNamePrefix(b.fmt("{s}-{s} ", .{1347 test_step.setNamePrefix(b.fmt("{s}-{s}-{s} ", .{
1345 "test-c-abi",1348 "test-c-abi",
1346 triple_prefix,1349 triple_prefix,
1350 @tagName(mode),
1347 }));1351 }));
13481352
1349 step.dependOn(&test_step.step);1353 step.dependOn(&test_step.step);
1350 }1354 };
1351 return step;1355 return step;
1352}1356}