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 {
439439 b.enable_wine,
440440 enable_symlinks_windows,
441441 ));
442 test_step.dependOn(tests.addCAbiTests(b, skip_non_native));
442 test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release));
443443 test_step.dependOn(tests.addLinkTests(b, test_filter, modes, enable_macos_sdk, skip_stage2_tests, enable_symlinks_windows));
444444 test_step.dependOn(tests.addStackTraceTests(b, test_filter, modes));
445445 test_step.dependOn(tests.addCliTests(b, test_filter, modes));
test/c_abi/main.zig+21-1
......@@ -4,7 +4,7 @@
44//! To run all the tests on the tier 1 architecture you can use:
55//! zig build test-c-abi -fqemu
66//! 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-bin
7//! zig test -lc main.zig cfuncs.c -target mips-linux --test-cmd qemu-mips --test-cmd-bin
88const std = @import("std");
99const builtin = @import("builtin");
1010const print = std.debug.print;
......@@ -764,6 +764,7 @@ extern fn c_float_array_struct(FloatArrayStruct) void;
764764extern fn c_ret_float_array_struct() FloatArrayStruct;
765765
766766test "Float array like struct" {
767 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
767768 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
768769 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
769770
......@@ -824,7 +825,9 @@ extern fn c_big_vec(BigVec) void;
824825extern fn c_ret_big_vec() BigVec;
825826
826827test "big simd vector" {
828 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
827829 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
829832 c_big_vec(.{ 1, 2, 3, 4, 5, 6, 7, 8 });
830833
......@@ -875,6 +878,8 @@ test "DC: Zig passes to C" {
875878 try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 }));
876879}
877880test "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;
878883 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
879884 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
880885 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
......@@ -888,6 +893,8 @@ test "DC: C passes to Zig" {
888893 try expectOk(c_send_DC());
889894}
890895test "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;
891898 if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
892899 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
893900 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
......@@ -920,13 +927,17 @@ test "CFF: Zig passes to C" {
920927 try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }));
921928}
922929test "CFF: Zig returns to C" {
930 if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
923931 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
924932 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
925933 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
926934 try expectOk(c_assert_ret_CFF());
927935}
928936test "CFF: C passes to Zig" {
937 if (builtin.cpu.arch == .x86_64 and builtin.mode != .Debug) return error.SkipZigTest;
929938 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;
930941 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
931942 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
932943 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
......@@ -934,6 +945,10 @@ test "CFF: C passes to Zig" {
934945 try expectOk(c_send_CFF());
935946}
936947test "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;
937952 if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
938953 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
939954 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
......@@ -967,6 +982,7 @@ test "PD: Zig passes to C" {
967982}
968983test "PD: Zig returns to C" {
969984 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
985 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
970986 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
971987 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
972988 try expectOk(c_assert_ret_PD());
......@@ -980,6 +996,7 @@ test "PD: C passes to Zig" {
980996}
981997test "PD: C returns to Zig" {
982998 if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
999 if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
9831000 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
9841001 if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
9851002 try expectEqual(c_ret_PD(), .{ .v1 = null, .v2 = 0.5 });
......@@ -1014,6 +1031,7 @@ extern fn c_modify_by_ref_param(ByRef) ByRef;
10141031
10151032test "C function modifies by ref param" {
10161033 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
10181036 const res = c_modify_by_ref_param(.{ .val = 1, .arr = undefined });
10191037 try expect(res.val == 42);
......@@ -1034,6 +1052,8 @@ const ByVal = extern struct {
10341052
10351053extern fn c_func_ptr_byval(*anyopaque, *anyopaque, ByVal, c_ulong, *anyopaque, c_ulong) void;
10361054test "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;
10371057 if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
10381058
10391059 var fn_ptr = &c_func_ptr_byval;
test/tests.zig+8-4
......@@ -1323,10 +1323,12 @@ const c_abi_targets = [_]CrossTarget{
13231323 },
13241324};
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 {
13271327 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| {
13301332 if (skip_non_native and !c_abi_target.isNative())
13311333 continue;
13321334
......@@ -1339,14 +1341,16 @@ pub fn addCAbiTests(b: *build.Builder, skip_non_native: bool) *build.Step {
13391341 }
13401342 test_step.linkLibC();
13411343 test_step.addCSourceFile("test/c_abi/cfuncs.c", &.{"-std=c99"});
1344 test_step.setBuildMode(mode);
13421345
13431346 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} ", .{
13451348 "test-c-abi",
13461349 triple_prefix,
1350 @tagName(mode),
13471351 }));
13481352
13491353 step.dependOn(&test_step.step);
1350 }
1354 };
13511355 return step;
13521356}