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 {...@@ -416,7 +416,7 @@ pub fn build(b: *std.Build) !void {
416 chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.ReleaseSmall;416 chosen_opt_modes_buf[chosen_mode_index] = builtin.OptimizeMode.ReleaseSmall;
417 chosen_mode_index += 1;417 chosen_mode_index += 1;
418 }418 }
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
421 const test_only: ?tests.ModuleTestOptions.TestOnly = if (no_matrix)421 const test_only: ?tests.ModuleTestOptions.TestOnly = if (no_matrix)
422 .default422 .default
...@@ -476,7 +476,7 @@ pub fn build(b: *std.Build) !void {...@@ -476,7 +476,7 @@ pub fn build(b: *std.Build) !void {
476 .root_src = "test/behavior.zig",476 .root_src = "test/behavior.zig",
477 .name = "behavior",477 .name = "behavior",
478 .desc = "Run the behavior tests",478 .desc = "Run the behavior tests",
479 .optimize_modes = optimization_modes,479 .optimize_modes = optimize_modes,
480 .include_paths = &.{},480 .include_paths = &.{},
481 .sanitize_thread = sanitize_thread,481 .sanitize_thread = sanitize_thread,
482 .skip_single_threaded = skip_single_threaded,482 .skip_single_threaded = skip_single_threaded,
...@@ -502,7 +502,7 @@ pub fn build(b: *std.Build) !void {...@@ -502,7 +502,7 @@ pub fn build(b: *std.Build) !void {
502 .root_src = "lib/compiler_rt.zig",502 .root_src = "lib/compiler_rt.zig",
503 .name = "compiler-rt",503 .name = "compiler-rt",
504 .desc = "Run the compiler_rt tests",504 .desc = "Run the compiler_rt tests",
505 .optimize_modes = optimization_modes,505 .optimize_modes = optimize_modes,
506 .include_paths = &.{},506 .include_paths = &.{},
507 .sanitize_thread = sanitize_thread,507 .sanitize_thread = sanitize_thread,
508 .skip_single_threaded = true,508 .skip_single_threaded = true,
...@@ -529,7 +529,7 @@ pub fn build(b: *std.Build) !void {...@@ -529,7 +529,7 @@ pub fn build(b: *std.Build) !void {
529 .root_src = "lib/std/std.zig",529 .root_src = "lib/std/std.zig",
530 .name = "std",530 .name = "std",
531 .desc = "Run the standard library tests",531 .desc = "Run the standard library tests",
532 .optimize_modes = optimization_modes,532 .optimize_modes = optimize_modes,
533 .include_paths = &.{},533 .include_paths = &.{},
534 .sanitize_thread = sanitize_thread,534 .sanitize_thread = sanitize_thread,
535 .skip_single_threaded = skip_single_threaded,535 .skip_single_threaded = skip_single_threaded,
...@@ -555,7 +555,7 @@ pub fn build(b: *std.Build) !void {...@@ -555,7 +555,7 @@ pub fn build(b: *std.Build) !void {
555 .root_src = "test/c.zig",555 .root_src = "test/c.zig",
556 .name = "libc",556 .name = "libc",
557 .desc = "Run the libc API tests",557 .desc = "Run the libc API tests",
558 .optimize_modes = optimization_modes,558 .optimize_modes = optimize_modes,
559 .include_paths = &.{},559 .include_paths = &.{},
560 .sanitize_thread = sanitize_thread,560 .sanitize_thread = sanitize_thread,
561 .skip_single_threaded = true,561 .skip_single_threaded = true,
...@@ -599,13 +599,14 @@ pub fn build(b: *std.Build) !void {...@@ -599,13 +599,14 @@ pub fn build(b: *std.Build) !void {
599599
600 test_step.dependOn(tests.addStandaloneTests(600 test_step.dependOn(tests.addStandaloneTests(
601 b,601 b,
602 optimization_modes,602 optimize_modes,
603 enable_macos_sdk,603 enable_macos_sdk,
604 enable_ios_sdk,604 enable_ios_sdk,
605 enable_symlinks_windows,605 enable_symlinks_windows,
606 ));606 ));
607 test_step.dependOn(tests.addCAbiTests(b, .{607 test_step.dependOn(tests.addCAbiTests(b, .{
608 .test_target_filters = test_target_filters,608 .test_target_filters = test_target_filters,
609 .optimize_modes = optimize_modes,
609 .skip_non_native = skip_non_native,610 .skip_non_native = skip_non_native,
610 .skip_wasm = skip_wasm,611 .skip_wasm = skip_wasm,
611 .skip_freebsd = skip_freebsd,612 .skip_freebsd = skip_freebsd,
...@@ -615,19 +616,18 @@ pub fn build(b: *std.Build) !void {...@@ -615,19 +616,18 @@ pub fn build(b: *std.Build) !void {
615 .skip_darwin = skip_darwin,616 .skip_darwin = skip_darwin,
616 .skip_linux = skip_linux,617 .skip_linux = skip_linux,
617 .skip_llvm = skip_llvm,618 .skip_llvm = skip_llvm,
618 .skip_release = skip_release,
619 .max_rss = 3_300_000_000,619 .max_rss = 3_300_000_000,
620 }));620 }));
621 test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, enable_symlinks_windows));621 test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, enable_symlinks_windows));
622 test_step.dependOn(tests.addStackTraceTests(b, test_filters, skip_non_native));622 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));
624 test_step.dependOn(tests.addCliTests(b));624 test_step.dependOn(tests.addCliTests(b));
625 if (tests.addDebuggerTests(b, .{625 if (tests.addDebuggerTests(b, .{
626 .test_filters = test_filters,626 .test_filters = test_filters,
627 .test_target_filters = test_target_filters,627 .test_target_filters = test_target_filters,
628 .gdb = b.option([]const u8, "gdb", "path to gdb binary"),628 .gdb = b.option([]const u8, "gdb", "path to gdb binary"),
629 .lldb = b.option([]const u8, "lldb", "path to lldb binary"),629 .lldb = b.option([]const u8, "lldb", "path to lldb binary"),
630 .optimize_modes = optimization_modes,630 .optimize_modes = optimize_modes,
631 .skip_single_threaded = skip_single_threaded,631 .skip_single_threaded = skip_single_threaded,
632 .skip_libc = skip_libc,632 .skip_libc = skip_libc,
633 })) |test_debugger_step| test_step.dependOn(test_debugger_step);633 })) |test_debugger_step| test_step.dependOn(test_debugger_step);
...@@ -663,7 +663,7 @@ pub fn build(b: *std.Build) !void {...@@ -663,7 +663,7 @@ pub fn build(b: *std.Build) !void {
663 if (!skip_test_incremental) test_step.dependOn(test_incremental_step);663 if (!skip_test_incremental) test_step.dependOn(test_incremental_step);
664664
665 if (tests.addLibcTestNszTests(b, .{665 if (tests.addLibcTestNszTests(b, .{
666 .optimize_modes = optimization_modes,666 .optimize_modes = optimize_modes,
667 .test_filters = test_filters,667 .test_filters = test_filters,
668 .test_target_filters = test_target_filters,668 .test_target_filters = test_target_filters,
669 .skip_wasm = skip_wasm,669 .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...@@ -2749,6 +2749,7 @@ pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: Opt
27492749
2750const CAbiTestOptions = struct {2750const CAbiTestOptions = struct {
2751 test_target_filters: []const []const u8,2751 test_target_filters: []const []const u8,
2752 optimize_modes: []const OptimizeMode,
2752 skip_non_native: bool,2753 skip_non_native: bool,
2753 skip_wasm: bool,2754 skip_wasm: bool,
2754 skip_freebsd: bool,2755 skip_freebsd: bool,
...@@ -2758,43 +2759,38 @@ const CAbiTestOptions = struct {...@@ -2758,43 +2759,38 @@ const CAbiTestOptions = struct {
2758 skip_darwin: bool,2759 skip_darwin: bool,
2759 skip_linux: bool,2760 skip_linux: bool,
2760 skip_llvm: bool,2761 skip_llvm: bool,
2761 skip_release: bool,
2762 max_rss: usize = 0,2762 max_rss: usize = 0,
2763};2763};
27642764
2765pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {2765pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
2766 const step = b.step("test-c-abi", "Run the C ABI tests");2766 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 (options.skip_wasm and c_abi_target.target.cpu_arch != null and c_abi_target.target.cpu_arch.?.isWasm()) continue;
2771 if (optimize_mode != .Debug and options.skip_release) continue;
27722772
2773 for (c_abi_targets) |c_abi_target| {2773 if (options.skip_freebsd and c_abi_target.target.os_tag == .freebsd) continue;
2774 if (options.skip_non_native and !c_abi_target.target.isNative()) 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;2784 if (options.test_target_filters.len > 0) {
2779 if (options.skip_netbsd and c_abi_target.target.os_tag == .netbsd) continue;2785 for (options.test_target_filters) |filter| {
2780 if (options.skip_openbsd and c_abi_target.target.os_tag == .openbsd) continue;2786 if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
2781 if (options.skip_windows and c_abi_target.target.os_tag == .windows) continue;2787 } else continue;
2782 if (options.skip_darwin and c_abi_target.target.os_tag != null and c_abi_target.target.os_tag.?.isDarwin()) continue;2788 }
2783 if (options.skip_linux and c_abi_target.target.os_tag == .linux) continue;
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);
2786 if (options.skip_llvm and would_use_llvm) continue;2792 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
2798 const test_mod = b.createModule(.{2794 const test_mod = b.createModule(.{
2799 .root_source_file = b.path("test/c_abi/main.zig"),2795 .root_source_file = b.path("test/c_abi/main.zig"),
2800 .target = resolved_target,2796 .target = resolved_target,