authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-06 00:27:46-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:13-07:00
log7bad6958657c6b4a791c73a3f827f7f848cab762
treed2c2ee46a950c9a7180c30cf862a590eb46b9d14
parentf51413d2cf0bd87079dace7f6481d2a361a19ea6

build.zig: annotate std lib tests maxrss


2 files changed, 74 insertions(+), 67 deletions(-)

build.zig+52-54
...@@ -402,47 +402,45 @@ pub fn build(b: *std.Build) !void {...@@ -402,47 +402,45 @@ pub fn build(b: *std.Build) !void {
402 const do_fmt_step = b.step("fmt", "Modify source files in place to have conforming formatting");402 const do_fmt_step = b.step("fmt", "Modify source files in place to have conforming formatting");
403 do_fmt_step.dependOn(&do_fmt.step);403 do_fmt_step.dependOn(&do_fmt.step);
404404
405 test_step.dependOn(tests.addPkgTests(405 test_step.dependOn(tests.addModuleTests(b, .{
406 b,406 .test_filter = test_filter,
407 test_filter,407 .root_src = "test/behavior.zig",
408 "test/behavior.zig",408 .name = "behavior",
409 "behavior",409 .desc = "Run the behavior tests",
410 "Run the behavior tests",410 .optimize_modes = optimization_modes,
411 optimization_modes,411 .skip_single_threaded = skip_single_threaded,
412 skip_single_threaded,412 .skip_non_native = skip_non_native,
413 skip_non_native,413 .skip_libc = skip_libc,
414 skip_libc,414 .skip_stage1 = skip_stage1,
415 skip_stage1,415 .skip_stage2 = skip_stage2_tests,
416 skip_stage2_tests,416 .max_rss = 1 * 1024 * 1024 * 1024,
417 ));417 }));
418418
419 test_step.dependOn(tests.addPkgTests(419 test_step.dependOn(tests.addModuleTests(b, .{
420 b,420 .test_filter = test_filter,
421 test_filter,421 .root_src = "lib/compiler_rt.zig",
422 "lib/compiler_rt.zig",422 .name = "compiler-rt",
423 "compiler-rt",423 .desc = "Run the compiler_rt tests",
424 "Run the compiler_rt tests",424 .optimize_modes = optimization_modes,
425 optimization_modes,425 .skip_single_threaded = true,
426 true, // skip_single_threaded426 .skip_non_native = skip_non_native,
427 skip_non_native,427 .skip_libc = true,
428 true, // skip_libc428 .skip_stage1 = skip_stage1,
429 skip_stage1,429 .skip_stage2 = true, // TODO get all these passing
430 skip_stage2_tests or true, // TODO get these all passing430 }));
431 ));431
432432 test_step.dependOn(tests.addModuleTests(b, .{
433 test_step.dependOn(tests.addPkgTests(433 .test_filter = test_filter,
434 b,434 .root_src = "lib/c.zig",
435 test_filter,435 .name = "universal-libc",
436 "lib/c.zig",436 .desc = "Run the universal libc tests",
437 "universal-libc",437 .optimize_modes = optimization_modes,
438 "Run the universal libc tests",438 .skip_single_threaded = true,
439 optimization_modes,439 .skip_non_native = skip_non_native,
440 true, // skip_single_threaded440 .skip_libc = true,
441 skip_non_native,441 .skip_stage1 = skip_stage1,
442 true, // skip_libc442 .skip_stage2 = true, // TODO get all these passing
443 skip_stage1,443 }));
444 skip_stage2_tests or true, // TODO get these all passing
445 ));
446444
447 test_step.dependOn(tests.addCompareOutputTests(b, test_filter, optimization_modes));445 test_step.dependOn(tests.addCompareOutputTests(b, test_filter, optimization_modes));
448 test_step.dependOn(tests.addStandaloneTests(446 test_step.dependOn(tests.addStandaloneTests(
...@@ -472,19 +470,19 @@ pub fn build(b: *std.Build) !void {...@@ -472,19 +470,19 @@ pub fn build(b: *std.Build) !void {
472 // tests for this feature are disabled until we have the self-hosted compiler available470 // tests for this feature are disabled until we have the self-hosted compiler available
473 // test_step.dependOn(tests.addGenHTests(b, test_filter));471 // test_step.dependOn(tests.addGenHTests(b, test_filter));
474472
475 test_step.dependOn(tests.addPkgTests(473 test_step.dependOn(tests.addModuleTests(b, .{
476 b,474 .test_filter = test_filter,
477 test_filter,475 .root_src = "lib/std/std.zig",
478 "lib/std/std.zig",476 .name = "std",
479 "std",477 .desc = "Run the standard library tests",
480 "Run the standard library tests",478 .optimize_modes = optimization_modes,
481 optimization_modes,479 .skip_single_threaded = skip_single_threaded,
482 skip_single_threaded,480 .skip_non_native = skip_non_native,
483 skip_non_native,481 .skip_libc = skip_libc,
484 skip_libc,482 .skip_stage1 = skip_stage1,
485 skip_stage1,483 .skip_stage2 = true, // TODO get all these passing
486 true, // TODO get these all passing484 .max_rss = 3 * 1024 * 1024 * 1024,
487 ));485 }));
488486
489 try addWasiUpdateStep(b, version);487 try addWasiUpdateStep(b, version);
490}488}
test/tests.zig+22-13
...@@ -639,8 +639,7 @@ pub fn addGenHTests(b: *std.Build, test_filter: ?[]const u8) *Step {...@@ -639,8 +639,7 @@ pub fn addGenHTests(b: *std.Build, test_filter: ?[]const u8) *Step {
639 return cases.step;639 return cases.step;
640}640}
641641
642pub fn addPkgTests(642const ModuleTestOptions = struct {
643 b: *std.Build,
644 test_filter: ?[]const u8,643 test_filter: ?[]const u8,
645 root_src: []const u8,644 root_src: []const u8,
646 name: []const u8,645 name: []const u8,
...@@ -651,14 +650,17 @@ pub fn addPkgTests(...@@ -651,14 +650,17 @@ pub fn addPkgTests(
651 skip_libc: bool,650 skip_libc: bool,
652 skip_stage1: bool,651 skip_stage1: bool,
653 skip_stage2: bool,652 skip_stage2: bool,
654) *Step {653 max_rss: usize = 0,
655 const step = b.step(b.fmt("test-{s}", .{name}), desc);654};
655
656pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
657 const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
656658
657 for (test_targets) |test_target| {659 for (test_targets) |test_target| {
658 if (skip_non_native and !test_target.target.isNative())660 if (options.skip_non_native and !test_target.target.isNative())
659 continue;661 continue;
660662
661 if (skip_libc and test_target.link_libc)663 if (options.skip_libc and test_target.link_libc)
662 continue;664 continue;
663665
664 if (test_target.link_libc and test_target.target.getOs().requiresLibC()) {666 if (test_target.link_libc and test_target.target.getOs().requiresLibC()) {
...@@ -666,7 +668,7 @@ pub fn addPkgTests(...@@ -666,7 +668,7 @@ pub fn addPkgTests(
666 continue;668 continue;
667 }669 }
668670
669 if (skip_single_threaded and test_target.single_threaded)671 if (options.skip_single_threaded and test_target.single_threaded)
670 continue;672 continue;
671673
672 if (test_target.disable_native and674 if (test_target.disable_native and
...@@ -677,12 +679,12 @@ pub fn addPkgTests(...@@ -677,12 +679,12 @@ pub fn addPkgTests(
677 }679 }
678680
679 if (test_target.backend) |backend| switch (backend) {681 if (test_target.backend) |backend| switch (backend) {
680 .stage1 => if (skip_stage1) continue,682 .stage1 => if (options.skip_stage1) continue,
681 .stage2_llvm => {},683 .stage2_llvm => {},
682 else => if (skip_stage2) continue,684 else => if (options.skip_stage2) continue,
683 };685 };
684686
685 const want_this_mode = for (optimize_modes) |m| {687 const want_this_mode = for (options.optimize_modes) |m| {
686 if (m == test_target.optimize_mode) break true;688 if (m == test_target.optimize_mode) break true;
687 } else false;689 } else false;
688 if (!want_this_mode) continue;690 if (!want_this_mode) continue;
...@@ -696,15 +698,22 @@ pub fn addPkgTests(...@@ -696,15 +698,22 @@ pub fn addPkgTests(
696698
697 const triple_prefix = test_target.target.zigTriple(b.allocator) catch unreachable;699 const triple_prefix = test_target.target.zigTriple(b.allocator) catch unreachable;
698700
701 // wasm32-wasi builds need more RAM, idk why
702 const max_rss = if (test_target.target.getOs().tag == .wasi)
703 options.max_rss * 2
704 else
705 options.max_rss;
706
699 const these_tests = b.addTest(.{707 const these_tests = b.addTest(.{
700 .root_source_file = .{ .path = root_src },708 .root_source_file = .{ .path = options.root_src },
701 .optimize = test_target.optimize_mode,709 .optimize = test_target.optimize_mode,
702 .target = test_target.target,710 .target = test_target.target,
711 .max_rss = max_rss,
703 });712 });
704 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";713 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";
705 const backend_txt = if (test_target.backend) |backend| @tagName(backend) else "default";714 const backend_txt = if (test_target.backend) |backend| @tagName(backend) else "default";
706 these_tests.setNamePrefix(b.fmt("{s}-{s}-{s}-{s}-{s}-{s} ", .{715 these_tests.setNamePrefix(b.fmt("{s}-{s}-{s}-{s}-{s}-{s} ", .{
707 name,716 options.name,
708 triple_prefix,717 triple_prefix,
709 @tagName(test_target.optimize_mode),718 @tagName(test_target.optimize_mode),
710 libc_prefix,719 libc_prefix,
...@@ -712,7 +721,7 @@ pub fn addPkgTests(...@@ -712,7 +721,7 @@ pub fn addPkgTests(
712 backend_txt,721 backend_txt,
713 }));722 }));
714 these_tests.single_threaded = test_target.single_threaded;723 these_tests.single_threaded = test_target.single_threaded;
715 these_tests.setFilter(test_filter);724 these_tests.setFilter(options.test_filter);
716 if (test_target.link_libc) {725 if (test_target.link_libc) {
717 these_tests.linkSystemLibrary("c");726 these_tests.linkSystemLibrary("c");
718 }727 }