authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-04-22 12:02:13-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-04-22 13:19:44-04:00
logea45895a2dd75200c36f9f51cb54384476224f89
treecfd895c352f8a289328fc9318d726945d79e1f02
parent9df02121d0d87c17173f79d55692bed9cb65722c

tests: cleanup c abi test runner


2 files changed, 30 insertions(+), 34 deletions(-)

build.zig+10-10
......@@ -416,7 +416,7 @@ pub fn build(b: *std.Build) !void {
416416 chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.ReleaseSmall;
417417 chosen_mode_index += 1;
418418 }
419 const optimization_modes = chosen_opt_modes_buf[0..chosen_mode_index];
419 const optimize_modes = chosen_opt_modes_buf[0..chosen_mode_index];
420420
421421 const test_only: ?tests.ModuleTestOptions.TestOnly = if (no_matrix)
422422 .default
......@@ -476,7 +476,7 @@ pub fn build(b: *std.Build) !void {
476476 .root_src = "test/behavior.zig",
477477 .name = "behavior",
478478 .desc = "Run the behavior tests",
479 .optimize_modes = optimization_modes,
479 .optimize_modes = optimize_modes,
480480 .include_paths = &.{},
481481 .sanitize_thread = sanitize_thread,
482482 .skip_single_threaded = skip_single_threaded,
......@@ -502,7 +502,7 @@ pub fn build(b: *std.Build) !void {
502502 .root_src = "lib/compiler_rt.zig",
503503 .name = "compiler-rt",
504504 .desc = "Run the compiler_rt tests",
505 .optimize_modes = optimization_modes,
505 .optimize_modes = optimize_modes,
506506 .include_paths = &.{},
507507 .sanitize_thread = sanitize_thread,
508508 .skip_single_threaded = true,
......@@ -529,7 +529,7 @@ pub fn build(b: *std.Build) !void {
529529 .root_src = "lib/std/std.zig",
530530 .name = "std",
531531 .desc = "Run the standard library tests",
532 .optimize_modes = optimization_modes,
532 .optimize_modes = optimize_modes,
533533 .include_paths = &.{},
534534 .sanitize_thread = sanitize_thread,
535535 .skip_single_threaded = skip_single_threaded,
......@@ -555,7 +555,7 @@ pub fn build(b: *std.Build) !void {
555555 .root_src = "test/c.zig",
556556 .name = "libc",
557557 .desc = "Run the libc API tests",
558 .optimize_modes = optimization_modes,
558 .optimize_modes = optimize_modes,
559559 .include_paths = &.{},
560560 .sanitize_thread = sanitize_thread,
561561 .skip_single_threaded = true,
......@@ -599,13 +599,14 @@ pub fn build(b: *std.Build) !void {
599599
600600 test_step.dependOn(tests.addStandaloneTests(
601601 b,
602 optimization_modes,
602 optimize_modes,
603603 enable_macos_sdk,
604604 enable_ios_sdk,
605605 enable_symlinks_windows,
606606 ));
607607 test_step.dependOn(tests.addCAbiTests(b, .{
608608 .test_target_filters = test_target_filters,
609 .optimize_modes = optimize_modes,
609610 .skip_non_native = skip_non_native,
610611 .skip_wasm = skip_wasm,
611612 .skip_freebsd = skip_freebsd,
......@@ -615,19 +616,18 @@ pub fn build(b: *std.Build) !void {
615616 .skip_darwin = skip_darwin,
616617 .skip_linux = skip_linux,
617618 .skip_llvm = skip_llvm,
618 .skip_release = skip_release,
619619 .max_rss = 3_300_000_000,
620620 }));
621621 test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, enable_symlinks_windows));
622622 test_step.dependOn(tests.addStackTraceTests(b, test_filters, skip_non_native));
623 test_step.dependOn(tests.addErrorTraceTests(b, test_filters, optimization_modes, skip_non_native));
623 test_step.dependOn(tests.addErrorTraceTests(b, test_filters, optimize_modes, skip_non_native));
624624 test_step.dependOn(tests.addCliTests(b));
625625 if (tests.addDebuggerTests(b, .{
626626 .test_filters = test_filters,
627627 .test_target_filters = test_target_filters,
628628 .gdb = b.option([]const u8, "gdb", "path to gdb binary"),
629629 .lldb = b.option([]const u8, "lldb", "path to lldb binary"),
630 .optimize_modes = optimization_modes,
630 .optimize_modes = optimize_modes,
631631 .skip_single_threaded = skip_single_threaded,
632632 .skip_libc = skip_libc,
633633 })) |test_debugger_step| test_step.dependOn(test_debugger_step);
......@@ -663,7 +663,7 @@ pub fn build(b: *std.Build) !void {
663663 if (!skip_test_incremental) test_step.dependOn(test_incremental_step);
664664
665665 if (tests.addLibcTestNszTests(b, .{
666 .optimize_modes = optimization_modes,
666 .optimize_modes = optimize_modes,
667667 .test_filters = test_filters,
668668 .test_target_filters = test_target_filters,
669669 .skip_wasm = skip_wasm,
test/tests.zig+20-24
......@@ -2749,6 +2749,7 @@ pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: Opt
27492749
27502750const CAbiTestOptions = struct {
27512751 test_target_filters: []const []const u8,
2752 optimize_modes: []const OptimizeMode,
27522753 skip_non_native: bool,
27532754 skip_wasm: bool,
27542755 skip_freebsd: bool,
......@@ -2758,43 +2759,38 @@ const CAbiTestOptions = struct {
27582759 skip_darwin: bool,
27592760 skip_linux: bool,
27602761 skip_llvm: bool,
2761 skip_release: bool,
27622762 max_rss: usize = 0,
27632763};
27642764
27652765pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
27662766 const step = b.step("test-c-abi", "Run the C ABI tests");
27672767
2768 const optimize_modes: [3]OptimizeMode = .{ .Debug, .ReleaseSafe, .ReleaseFast };
2768 for (c_abi_targets) |c_abi_target| {
2769 if (options.skip_non_native and !c_abi_target.target.isNative()) continue;
27692770
2770 for (optimize_modes) |optimize_mode| {
2771 if (optimize_mode != .Debug and options.skip_release) continue;
2771 if (options.skip_wasm and c_abi_target.target.cpu_arch != null and c_abi_target.target.cpu_arch.?.isWasm()) continue;
27722772
2773 for (c_abi_targets) |c_abi_target| {
2774 if (options.skip_non_native and !c_abi_target.target.isNative()) continue;
2773 if (options.skip_freebsd and c_abi_target.target.os_tag == .freebsd) continue;
2774 if (options.skip_netbsd and c_abi_target.target.os_tag == .netbsd) continue;
2775 if (options.skip_openbsd and c_abi_target.target.os_tag == .openbsd) continue;
2776 if (options.skip_windows and c_abi_target.target.os_tag == .windows) continue;
2777 if (options.skip_darwin and c_abi_target.target.os_tag != null and c_abi_target.target.os_tag.?.isDarwin()) continue;
2778 if (options.skip_linux and c_abi_target.target.os_tag == .linux) continue;
27752779
2776 if (options.skip_wasm and c_abi_target.target.cpu_arch != null and c_abi_target.target.cpu_arch.?.isWasm()) continue;
2780 const resolved_target = b.resolveTargetQuery(c_abi_target.target);
2781 const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
2782 const target = &resolved_target.result;
27772783
2778 if (options.skip_freebsd and c_abi_target.target.os_tag == .freebsd) continue;
2779 if (options.skip_netbsd and c_abi_target.target.os_tag == .netbsd) continue;
2780 if (options.skip_openbsd and c_abi_target.target.os_tag == .openbsd) continue;
2781 if (options.skip_windows and c_abi_target.target.os_tag == .windows) continue;
2782 if (options.skip_darwin and c_abi_target.target.os_tag != null and c_abi_target.target.os_tag.?.isDarwin()) continue;
2783 if (options.skip_linux and c_abi_target.target.os_tag == .linux) continue;
2784 if (options.test_target_filters.len > 0) {
2785 for (options.test_target_filters) |filter| {
2786 if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
2787 } else continue;
2788 }
27842789
2785 const would_use_llvm = wouldUseLlvm(c_abi_target.use_llvm, c_abi_target.target, .Debug);
2790 for (options.optimize_modes) |optimize_mode| {
2791 const would_use_llvm = wouldUseLlvm(c_abi_target.use_llvm, c_abi_target.target, optimize_mode);
27862792 if (options.skip_llvm and would_use_llvm) continue;
27872793
2788 const resolved_target = b.resolveTargetQuery(c_abi_target.target);
2789 const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
2790 const target = &resolved_target.result;
2791
2792 if (options.test_target_filters.len > 0) {
2793 for (options.test_target_filters) |filter| {
2794 if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
2795 } else continue;
2796 }
2797
27982794 const test_mod = b.createModule(.{
27992795 .root_source_file = b.path("test/c_abi/main.zig"),
28002796 .target = resolved_target,