authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-04-16 12:43:35-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-04-16 12:43:35-07:00
logb0186f31002760c9940d8c06c2ac7baa9d52f404
tree25bb2c86739f6ee3d9cd8a9e5f77d046c4b12487
parent397649fb0934b75122e795bfb234d46693425d98
parent9e6647582da0d7cbf8a441cefea0bb9fae18bb5c
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #15277 from ziglang/tests

add CI test coverage for more target combinations

15 files changed, 359 insertions(+), 144 deletions(-)

build.zig+4-17
......@@ -85,9 +85,7 @@ pub fn build(b: *std.Build) !void {
8585 const skip_cross_glibc = b.option(bool, "skip-cross-glibc", "Main test suite skips builds that require cross glibc") orelse false;
8686 const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;
8787 const skip_single_threaded = b.option(bool, "skip-single-threaded", "Main test suite skips tests that are single-threaded") orelse false;
88 const skip_stage1 = b.option(bool, "skip-stage1", "Main test suite skips stage1 compile error tests") orelse false;
8988 const skip_run_translated_c = b.option(bool, "skip-run-translated-c", "Main test suite skips run-translated-c tests") orelse false;
90 const skip_stage2_tests = b.option(bool, "skip-stage2-tests", "Main test suite skips self-hosted compiler tests") orelse false;
9189
9290 const only_install_lib_files = b.option(bool, "lib-files-only", "Only install library files") orelse false;
9391
......@@ -187,9 +185,7 @@ pub fn build(b: *std.Build) !void {
187185 const compile_step = b.step("compile", "Build the self-hosted compiler");
188186 compile_step.dependOn(&exe.step);
189187
190 if (!skip_stage2_tests) {
191 test_step.dependOn(&exe.step);
192 }
188 test_step.dependOn(&exe.step);
193189
194190 exe.single_threaded = single_threaded;
195191
......@@ -360,7 +356,6 @@ pub fn build(b: *std.Build) !void {
360356 test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots);
361357 test_cases_options.addOption(bool, "skip_non_native", skip_non_native);
362358 test_cases_options.addOption(bool, "skip_cross_glibc", skip_cross_glibc);
363 test_cases_options.addOption(bool, "skip_stage1", skip_stage1);
364359 test_cases_options.addOption(bool, "have_llvm", enable_llvm);
365360 test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);
366361 test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
......@@ -416,7 +411,7 @@ pub fn build(b: *std.Build) !void {
416411
417412 const test_cases_step = b.step("test-cases", "Run the main compiler test cases");
418413 try tests.addCases(b, test_cases_step, test_filter, check_case_exe);
419 if (!skip_stage2_tests) test_step.dependOn(test_cases_step);
414 test_step.dependOn(test_cases_step);
420415
421416 test_step.dependOn(tests.addModuleTests(b, .{
422417 .test_filter = test_filter,
......@@ -428,8 +423,6 @@ pub fn build(b: *std.Build) !void {
428423 .skip_non_native = skip_non_native,
429424 .skip_cross_glibc = skip_cross_glibc,
430425 .skip_libc = skip_libc,
431 .skip_stage1 = skip_stage1,
432 .skip_stage2 = skip_stage2_tests,
433426 .max_rss = 1 * 1024 * 1024 * 1024,
434427 }));
435428
......@@ -443,8 +436,6 @@ pub fn build(b: *std.Build) !void {
443436 .skip_non_native = skip_non_native,
444437 .skip_cross_glibc = skip_cross_glibc,
445438 .skip_libc = true,
446 .skip_stage1 = skip_stage1,
447 .skip_stage2 = true, // TODO get all these passing
448439 }));
449440
450441 test_step.dependOn(tests.addModuleTests(b, .{
......@@ -457,8 +448,6 @@ pub fn build(b: *std.Build) !void {
457448 .skip_non_native = skip_non_native,
458449 .skip_cross_glibc = skip_cross_glibc,
459450 .skip_libc = true,
460 .skip_stage1 = skip_stage1,
461 .skip_stage2 = true, // TODO get all these passing
462451 }));
463452
464453 test_step.dependOn(tests.addCompareOutputTests(b, test_filter, optimization_modes));
......@@ -466,11 +455,11 @@ pub fn build(b: *std.Build) !void {
466455 b,
467456 optimization_modes,
468457 enable_macos_sdk,
469 skip_stage2_tests,
458 false,
470459 enable_symlinks_windows,
471460 ));
472461 test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release));
473 test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, skip_stage2_tests, enable_symlinks_windows));
462 test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, false, enable_symlinks_windows));
474463 test_step.dependOn(tests.addStackTraceTests(b, test_filter, optimization_modes));
475464 test_step.dependOn(tests.addCliTests(b));
476465 test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, optimization_modes));
......@@ -489,8 +478,6 @@ pub fn build(b: *std.Build) !void {
489478 .skip_non_native = skip_non_native,
490479 .skip_cross_glibc = skip_cross_glibc,
491480 .skip_libc = skip_libc,
492 .skip_stage1 = skip_stage1,
493 .skip_stage2 = true, // TODO get all these passing
494481 // I observed a value of 3398275072 on my M1, and multiplied by 1.1 to
495482 // get this amount:
496483 .max_rss = 3738102579,
lib/compiler_rt/common.zig+2-1
......@@ -6,7 +6,8 @@ pub const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal el
66/// Determines the symbol's visibility to other objects.
77/// For WebAssembly this allows the symbol to be resolved to other modules, but will not
88/// export it to the host runtime.
9pub const visibility: std.builtin.SymbolVisibility = if (builtin.target.isWasm()) .hidden else .default;
9pub const visibility: std.builtin.SymbolVisibility =
10 if (builtin.target.isWasm() and linkage != .Internal) .hidden else .default;
1011pub const want_aeabi = switch (builtin.abi) {
1112 .eabi,
1213 .eabihf,
lib/std/Build.zig+41-2
......@@ -454,6 +454,10 @@ pub const ExecutableOptions = struct {
454454 optimize: std.builtin.Mode = .Debug,
455455 linkage: ?CompileStep.Linkage = null,
456456 max_rss: usize = 0,
457 link_libc: ?bool = null,
458 single_threaded: ?bool = null,
459 use_llvm: ?bool = null,
460 use_lld: ?bool = null,
457461};
458462
459463pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {
......@@ -466,6 +470,10 @@ pub fn addExecutable(b: *Build, options: ExecutableOptions) *CompileStep {
466470 .kind = .exe,
467471 .linkage = options.linkage,
468472 .max_rss = options.max_rss,
473 .link_libc = options.link_libc,
474 .single_threaded = options.single_threaded,
475 .use_llvm = options.use_llvm,
476 .use_lld = options.use_lld,
469477 });
470478}
471479
......@@ -475,6 +483,10 @@ pub const ObjectOptions = struct {
475483 target: CrossTarget,
476484 optimize: std.builtin.Mode,
477485 max_rss: usize = 0,
486 link_libc: ?bool = null,
487 single_threaded: ?bool = null,
488 use_llvm: ?bool = null,
489 use_lld: ?bool = null,
478490};
479491
480492pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {
......@@ -485,6 +497,10 @@ pub fn addObject(b: *Build, options: ObjectOptions) *CompileStep {
485497 .optimize = options.optimize,
486498 .kind = .obj,
487499 .max_rss = options.max_rss,
500 .link_libc = options.link_libc,
501 .single_threaded = options.single_threaded,
502 .use_llvm = options.use_llvm,
503 .use_lld = options.use_lld,
488504 });
489505}
490506
......@@ -495,6 +511,10 @@ pub const SharedLibraryOptions = struct {
495511 target: CrossTarget,
496512 optimize: std.builtin.Mode,
497513 max_rss: usize = 0,
514 link_libc: ?bool = null,
515 single_threaded: ?bool = null,
516 use_llvm: ?bool = null,
517 use_lld: ?bool = null,
498518};
499519
500520pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {
......@@ -507,6 +527,10 @@ pub fn addSharedLibrary(b: *Build, options: SharedLibraryOptions) *CompileStep {
507527 .target = options.target,
508528 .optimize = options.optimize,
509529 .max_rss = options.max_rss,
530 .link_libc = options.link_libc,
531 .single_threaded = options.single_threaded,
532 .use_llvm = options.use_llvm,
533 .use_lld = options.use_lld,
510534 });
511535}
512536
......@@ -517,6 +541,10 @@ pub const StaticLibraryOptions = struct {
517541 optimize: std.builtin.Mode,
518542 version: ?std.builtin.Version = null,
519543 max_rss: usize = 0,
544 link_libc: ?bool = null,
545 single_threaded: ?bool = null,
546 use_llvm: ?bool = null,
547 use_lld: ?bool = null,
520548};
521549
522550pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {
......@@ -529,6 +557,10 @@ pub fn addStaticLibrary(b: *Build, options: StaticLibraryOptions) *CompileStep {
529557 .target = options.target,
530558 .optimize = options.optimize,
531559 .max_rss = options.max_rss,
560 .link_libc = options.link_libc,
561 .single_threaded = options.single_threaded,
562 .use_llvm = options.use_llvm,
563 .use_lld = options.use_lld,
532564 });
533565}
534566
......@@ -541,6 +573,10 @@ pub const TestOptions = struct {
541573 max_rss: usize = 0,
542574 filter: ?[]const u8 = null,
543575 test_runner: ?[]const u8 = null,
576 link_libc: ?bool = null,
577 single_threaded: ?bool = null,
578 use_llvm: ?bool = null,
579 use_lld: ?bool = null,
544580};
545581
546582pub fn addTest(b: *Build, options: TestOptions) *CompileStep {
......@@ -553,6 +589,10 @@ pub fn addTest(b: *Build, options: TestOptions) *CompileStep {
553589 .max_rss = options.max_rss,
554590 .filter = options.filter,
555591 .test_runner = options.test_runner,
592 .link_libc = options.link_libc,
593 .single_threaded = options.single_threaded,
594 .use_llvm = options.use_llvm,
595 .use_lld = options.use_lld,
556596 });
557597}
558598
......@@ -639,8 +679,7 @@ pub fn addRunArtifact(b: *Build, exe: *CompileStep) *RunStep {
639679 run_step.addArtifactArg(exe);
640680
641681 if (exe.kind == .@"test") {
642 run_step.stdio = .zig_test;
643 run_step.addArgs(&.{"--listen=-"});
682 run_step.enableTestRunnerMode();
644683 }
645684
646685 if (exe.vcpkg_bin_path) |path| {
lib/std/Build/CompileStep.zig+15-5
......@@ -63,7 +63,7 @@ emit_llvm_ir: EmitOption = .default,
6363// so it is not an EmitOption for now.
6464emit_h: bool = false,
6565bundle_compiler_rt: ?bool = null,
66single_threaded: ?bool = null,
66single_threaded: ?bool,
6767stack_protector: ?bool = null,
6868disable_stack_probing: bool,
6969disable_sanitize_c: bool,
......@@ -101,8 +101,8 @@ link_objects: ArrayList(LinkObject),
101101include_dirs: ArrayList(IncludeDir),
102102c_macros: ArrayList([]const u8),
103103installed_headers: ArrayList(*Step),
104is_linking_libc: bool = false,
105is_linking_libcpp: bool = false,
104is_linking_libc: bool,
105is_linking_libcpp: bool,
106106vcpkg_bin_path: ?[]const u8 = null,
107107
108108/// This may be set in order to override the default install directory
......@@ -207,8 +207,8 @@ force_undefined_symbols: std.StringHashMap(void),
207207stack_size: ?u64 = null,
208208
209209want_lto: ?bool = null,
210use_llvm: ?bool = null,
211use_lld: ?bool = null,
210use_llvm: ?bool,
211use_lld: ?bool,
212212
213213/// This is an advanced setting that can change the intent of this CompileStep.
214214/// If this slice has nonzero length, it means that this CompileStep exists to
......@@ -287,6 +287,10 @@ pub const Options = struct {
287287 max_rss: usize = 0,
288288 filter: ?[]const u8 = null,
289289 test_runner: ?[]const u8 = null,
290 link_libc: ?bool = null,
291 single_threaded: ?bool = null,
292 use_llvm: ?bool = null,
293 use_lld: ?bool = null,
290294};
291295
292296pub const Kind = enum {
......@@ -412,6 +416,12 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep {
412416 .output_dirname_source = GeneratedFile{ .step = &self.step },
413417
414418 .target_info = target_info,
419
420 .is_linking_libc = options.link_libc orelse false,
421 .is_linking_libcpp = false,
422 .single_threaded = options.single_threaded,
423 .use_llvm = options.use_llvm,
424 .use_lld = options.use_lld,
415425 };
416426
417427 if (self.kind == .lib) {
lib/std/Build/RunStep.zig+5
......@@ -140,6 +140,11 @@ pub fn setName(self: *RunStep, name: []const u8) void {
140140 self.rename_step_with_output_arg = false;
141141}
142142
143pub fn enableTestRunnerMode(rs: *RunStep) void {
144 rs.stdio = .zig_test;
145 rs.addArgs(&.{"--listen=-"});
146}
147
143148pub fn addArtifactArg(self: *RunStep, artifact: *CompileStep) void {
144149 self.argv.append(Arg{ .artifact = artifact }) catch @panic("OOM");
145150 self.step.dependOn(&artifact.step);
lib/std/zig/Server.zig+4-8
......@@ -104,11 +104,9 @@ pub fn receiveMessage(s: *Server) !InMessage.Header {
104104 const buf = fifo.readableSlice(0);
105105 assert(fifo.readableLength() == buf.len);
106106 if (buf.len >= @sizeOf(Header)) {
107 const header = @ptrCast(*align(1) const Header, buf[0..@sizeOf(Header)]);
108107 // workaround for https://github.com/ziglang/zig/issues/14904
109 const bytes_len = bswap_and_workaround_u32(&header.bytes_len);
110 // workaround for https://github.com/ziglang/zig/issues/14904
111 const tag = bswap_and_workaround_tag(&header.tag);
108 const bytes_len = bswap_and_workaround_u32(buf[4..][0..4]);
109 const tag = bswap_and_workaround_tag(buf[0..][0..4]);
112110
113111 if (buf.len - @sizeOf(Header) >= bytes_len) {
114112 fifo.discard(@sizeOf(Header));
......@@ -281,14 +279,12 @@ fn bswap_u32_array(slice: []u32) void {
281279}
282280
283281/// workaround for https://github.com/ziglang/zig/issues/14904
284fn bswap_and_workaround_u32(x: *align(1) const u32) u32 {
285 const bytes_ptr = @ptrCast(*const [4]u8, x);
282fn bswap_and_workaround_u32(bytes_ptr: *const [4]u8) u32 {
286283 return std.mem.readIntLittle(u32, bytes_ptr);
287284}
288285
289286/// workaround for https://github.com/ziglang/zig/issues/14904
290fn bswap_and_workaround_tag(x: *align(1) const InMessage.Tag) InMessage.Tag {
291 const bytes_ptr = @ptrCast(*const [4]u8, x);
287fn bswap_and_workaround_tag(bytes_ptr: *const [4]u8) InMessage.Tag {
292288 const int = std.mem.readIntLittle(u32, bytes_ptr);
293289 return @intToEnum(InMessage.Tag, int);
294290}
test/behavior/atomics.zig+6
......@@ -209,6 +209,12 @@ test "atomicrmw with floats" {
209209 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
210210 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
211211
212 if (builtin.zig_backend == .stage2_c) {
213 // TODO: test.c:34929:7: error: address argument to atomic operation must be a pointer to integer or pointer ('zig_f32 *' (aka 'float *') invalid
214 // when compiling with -std=c99 -pedantic
215 return error.SkipZigTest;
216 }
217
212218 if ((builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) and
213219 builtin.cpu.arch == .aarch64)
214220 {
test/behavior/bugs/12680.zig+4
......@@ -11,6 +11,10 @@ test "export a function twice" {
1111 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
1212 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
1313 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
14 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
15 // TODO: test.c: error: aliases are not supported on darwin
16 return error.SkipZigTest;
17 }
1418
1519 // If it exports the function correctly, `test_func` and `testFunc` will points to the same address.
1620 try expectEqual(test_func(), other_file.testFunc());
test/behavior/cast.zig+20
......@@ -1313,6 +1313,16 @@ test "cast f16 to wider types" {
13131313 if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
13141314 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
13151315
1316 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
1317 // TODO: test is failing
1318 return error.SkipZigTest;
1319 }
1320
1321 if (builtin.os.tag == .windows and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) {
1322 // TODO: test is failing
1323 return error.SkipZigTest;
1324 }
1325
13161326 const S = struct {
13171327 fn doTheTest() !void {
13181328 var x: f16 = 1234.0;
......@@ -1339,6 +1349,11 @@ test "cast f128 to narrower types" {
13391349 return error.SkipZigTest;
13401350 }
13411351
1352 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
1353 // TODO: test is failing
1354 return error.SkipZigTest;
1355 }
1356
13421357 const S = struct {
13431358 fn doTheTest() !void {
13441359 var x: f128 = 1234.0;
......@@ -1429,6 +1444,11 @@ test "coerce between pointers of compatible differently-named floats" {
14291444 return error.SkipZigTest;
14301445 }
14311446
1447 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) {
1448 // TODO: test is failing
1449 return error.SkipZigTest;
1450 }
1451
14321452 const F = switch (@typeInfo(c_longdouble).Float.bits) {
14331453 16 => f16,
14341454 32 => f32,
test/behavior/floatop.zig+35
......@@ -542,6 +542,11 @@ test "another, possibly redundant, @fabs test" {
542542 return error.SkipZigTest;
543543 }
544544
545 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
546 // TODO: test is failing
547 return error.SkipZigTest;
548 }
549
545550 try testFabsLegacy(f128, 12.0);
546551 comptime try testFabsLegacy(f128, 12.0);
547552 try testFabsLegacy(f64, 12.0);
......@@ -586,6 +591,11 @@ test "a third @fabs test, surely there should not be three fabs tests" {
586591 return error.SkipZigTest;
587592 }
588593
594 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
595 // TODO: test is failing
596 return error.SkipZigTest;
597 }
598
589599 inline for ([_]type{ f16, f32, f64, f80, f128, c_longdouble }) |T| {
590600 // normals
591601 try expect(@fabs(@as(T, 1.0)) == 1.0);
......@@ -688,6 +698,11 @@ test "@floor f128" {
688698 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
689699 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
690700
701 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
702 // TODO: test is failing
703 return error.SkipZigTest;
704 }
705
691706 try testFloorLegacy(f128, 12.0);
692707 comptime try testFloorLegacy(f128, 12.0);
693708}
......@@ -778,6 +793,11 @@ test "@ceil f128" {
778793 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
779794 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
780795
796 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) {
797 // TODO: test is failing
798 return error.SkipZigTest;
799 }
800
781801 try testCeilLegacy(f128, 12.0);
782802 comptime try testCeilLegacy(f128, 12.0);
783803}
......@@ -874,6 +894,11 @@ test "@trunc f128" {
874894 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
875895 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
876896
897 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
898 // TODO: test is failing
899 return error.SkipZigTest;
900 }
901
877902 try testTruncLegacy(f128, 12.0);
878903 comptime try testTruncLegacy(f128, 12.0);
879904}
......@@ -992,6 +1017,11 @@ test "negation f128" {
9921017 return error.SkipZigTest;
9931018 }
9941019
1020 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
1021 // TODO: test is failing
1022 return error.SkipZigTest;
1023 }
1024
9951025 const S = struct {
9961026 fn doTheTest() !void {
9971027 var a: f128 = 1;
......@@ -1035,6 +1065,11 @@ test "comptime fixed-width float zero divided by zero produces NaN" {
10351065 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
10361066 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
10371067
1068 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) {
1069 // TODO: test is failing
1070 return error.SkipZigTest;
1071 }
1072
10381073 inline for (.{ f16, f32, f64, f80, f128 }) |F| {
10391074 try expect(math.isNan(@as(F, 0) / @as(F, 0)));
10401075 }
test/behavior/math.zig+36
......@@ -622,6 +622,11 @@ test "f128" {
622622 return error.SkipZigTest;
623623 }
624624
625 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
626 // TODO: test is failing
627 return error.SkipZigTest;
628 }
629
625630 try test_f128();
626631 comptime try test_f128();
627632}
......@@ -1299,6 +1304,11 @@ test "remainder division" {
12991304 return error.SkipZigTest;
13001305 }
13011306
1307 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
1308 // TODO: test is failing
1309 return error.SkipZigTest;
1310 }
1311
13021312 comptime try remdiv(f16);
13031313 comptime try remdiv(f32);
13041314 comptime try remdiv(f64);
......@@ -1330,6 +1340,11 @@ test "float remainder division using @rem" {
13301340 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
13311341 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
13321342
1343 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) {
1344 // TODO: test is failing
1345 return error.SkipZigTest;
1346 }
1347
13331348 comptime try frem(f16);
13341349 comptime try frem(f32);
13351350 comptime try frem(f64);
......@@ -1372,6 +1387,11 @@ test "float modulo division using @mod" {
13721387 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
13731388 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
13741389
1390 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .x86_64) {
1391 // TODO: test is failing
1392 return error.SkipZigTest;
1393 }
1394
13751395 comptime try fmod(f16);
13761396 comptime try fmod(f32);
13771397 comptime try fmod(f64);
......@@ -1445,6 +1465,11 @@ test "@round f128" {
14451465 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
14461466 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
14471467
1468 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
1469 // TODO: test is failing
1470 return error.SkipZigTest;
1471 }
1472
14481473 try testRound(f128, 12.0);
14491474 comptime try testRound(f128, 12.0);
14501475}
......@@ -1490,6 +1515,11 @@ test "NaN comparison" {
14901515 return error.SkipZigTest;
14911516 }
14921517
1518 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
1519 // TODO: test is failing
1520 return error.SkipZigTest;
1521 }
1522
14931523 try testNanEqNan(f16);
14941524 try testNanEqNan(f32);
14951525 try testNanEqNan(f64);
......@@ -1562,6 +1592,12 @@ test "signed zeros are represented properly" {
15621592 if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64 and
15631593 builtin.zig_backend == .stage2_c)
15641594 {
1595 // TODO: test is failing
1596 return error.SkipZigTest;
1597 }
1598
1599 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) {
1600 // TODO: test is failing
15651601 return error.SkipZigTest;
15661602 }
15671603
test/behavior/muladd.zig+10
......@@ -75,6 +75,11 @@ test "@mulAdd f128" {
7575 return error.SkipZigTest;
7676 }
7777
78 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
79 // TODO: test is failing
80 return error.SkipZigTest;
81 }
82
7883 comptime try testMulAdd128();
7984 try testMulAdd128();
8085}
......@@ -203,6 +208,11 @@ test "vector f128" {
203208 return error.SkipZigTest;
204209 }
205210
211 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c and builtin.cpu.arch == .aarch64) {
212 // TODO: test is failing
213 return error.SkipZigTest;
214 }
215
206216 comptime try vector128();
207217 try vector128();
208218}
test/behavior/vector.zig+5
......@@ -103,6 +103,11 @@ test "vector float operators" {
103103 return error.SkipZigTest;
104104 }
105105
106 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
107 // TODO: test is failing
108 return error.SkipZigTest;
109 }
110
106111 inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| {
107112 const S = struct {
108113 fn doTheTest() !void {
test/behavior/widening.zig+10
......@@ -50,6 +50,11 @@ test "float widening" {
5050 return error.SkipZigTest;
5151 }
5252
53 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
54 // TODO: test is failing
55 return error.SkipZigTest;
56 }
57
5358 var a: f16 = 12.34;
5459 var b: f32 = a;
5560 var c: f64 = b;
......@@ -77,6 +82,11 @@ test "float widening f16 to f128" {
7782 return error.SkipZigTest;
7883 }
7984
85 if (builtin.os.tag == .macos and builtin.zig_backend == .stage2_c) {
86 // TODO: test is failing
87 return error.SkipZigTest;
88 }
89
8090 var x: f16 = 12.34;
8191 var y: f128 = x;
8292 try expect(x == y);
test/tests.zig+162-111
......@@ -22,12 +22,12 @@ pub const CompareOutputContext = @import("src/CompareOutput.zig");
2222pub const StackTracesContext = @import("src/StackTrace.zig");
2323
2424const TestTarget = struct {
25 target: CrossTarget = @as(CrossTarget, .{}),
25 target: CrossTarget = .{},
2626 optimize_mode: std.builtin.OptimizeMode = .Debug,
27 link_libc: bool = false,
28 single_threaded: bool = false,
29 disable_native: bool = false,
30 backend: ?std.builtin.CompilerBackend = null,
27 link_libc: ?bool = null,
28 single_threaded: ?bool = null,
29 use_llvm: ?bool = null,
30 use_lld: ?bool = null,
3131};
3232
3333const test_targets = blk: {
......@@ -43,13 +43,47 @@ const test_targets = blk: {
4343 .{
4444 .single_threaded = true,
4545 },
46 .{
47 .optimize_mode = .ReleaseFast,
48 },
49 .{
50 .link_libc = true,
51 .optimize_mode = .ReleaseFast,
52 },
53 .{
54 .optimize_mode = .ReleaseFast,
55 .single_threaded = true,
56 },
57
58 .{
59 .optimize_mode = .ReleaseSafe,
60 },
61 .{
62 .link_libc = true,
63 .optimize_mode = .ReleaseSafe,
64 },
65 .{
66 .optimize_mode = .ReleaseSafe,
67 .single_threaded = true,
68 },
69
70 .{
71 .optimize_mode = .ReleaseSmall,
72 },
73 .{
74 .link_libc = true,
75 .optimize_mode = .ReleaseSmall,
76 },
77 .{
78 .optimize_mode = .ReleaseSmall,
79 .single_threaded = true,
80 },
4681
4782 .{
4883 .target = .{
4984 .ofmt = .c,
5085 },
5186 .link_libc = true,
52 .backend = .stage2_c,
5387 },
5488 .{
5589 .target = .{
......@@ -57,22 +91,24 @@ const test_targets = blk: {
5791 .os_tag = .linux,
5892 .abi = .none,
5993 },
60 .backend = .stage2_x86_64,
94 .use_llvm = false,
95 .use_lld = false,
6196 },
6297 .{
6398 .target = .{
6499 .cpu_arch = .aarch64,
65100 .os_tag = .linux,
66101 },
67 .backend = .stage2_aarch64,
102 .use_llvm = false,
103 .use_lld = false,
68104 },
69105 .{
70106 .target = .{
71107 .cpu_arch = .wasm32,
72108 .os_tag = .wasi,
73109 },
74 .single_threaded = true,
75 .backend = .stage2_wasm,
110 .use_llvm = false,
111 .use_lld = false,
76112 },
77113 // https://github.com/ziglang/zig/issues/13623
78114 //.{
......@@ -80,7 +116,8 @@ const test_targets = blk: {
80116 // .cpu_arch = .arm,
81117 // .os_tag = .linux,
82118 // },
83 // .backend = .stage2_arm,
119 // .use_llvm = false,
120 // .use_lld = false,
84121 //},
85122 // https://github.com/ziglang/zig/issues/13623
86123 //.{
......@@ -88,7 +125,8 @@ const test_targets = blk: {
88125 // .arch_os_abi = "arm-linux-none",
89126 // .cpu_features = "generic+v8a",
90127 // }) catch unreachable,
91 // .backend = .stage2_arm,
128 // .use_llvm = false,
129 // .use_lld = false,
92130 //},
93131 .{
94132 .target = .{
......@@ -96,7 +134,8 @@ const test_targets = blk: {
96134 .os_tag = .macos,
97135 .abi = .none,
98136 },
99 .backend = .stage2_aarch64,
137 .use_llvm = false,
138 .use_lld = false,
100139 },
101140 .{
102141 .target = .{
......@@ -104,7 +143,8 @@ const test_targets = blk: {
104143 .os_tag = .macos,
105144 .abi = .none,
106145 },
107 .backend = .stage2_x86_64,
146 .use_llvm = false,
147 .use_lld = false,
108148 },
109149 .{
110150 .target = .{
......@@ -112,7 +152,8 @@ const test_targets = blk: {
112152 .os_tag = .windows,
113153 .abi = .gnu,
114154 },
115 .backend = .stage2_x86_64,
155 .use_llvm = false,
156 .use_lld = false,
116157 },
117158
118159 .{
......@@ -121,7 +162,6 @@ const test_targets = blk: {
121162 .os_tag = .wasi,
122163 },
123164 .link_libc = false,
124 .single_threaded = true,
125165 },
126166 .{
127167 .target = .{
......@@ -129,7 +169,6 @@ const test_targets = blk: {
129169 .os_tag = .wasi,
130170 },
131171 .link_libc = true,
132 .single_threaded = true,
133172 },
134173
135174 .{
......@@ -413,43 +452,6 @@ const test_targets = blk: {
413452 },
414453 .link_libc = true,
415454 },
416
417 // Do the release tests last because they take a long time
418 .{
419 .optimize_mode = .ReleaseFast,
420 },
421 .{
422 .link_libc = true,
423 .optimize_mode = .ReleaseFast,
424 },
425 .{
426 .optimize_mode = .ReleaseFast,
427 .single_threaded = true,
428 },
429
430 .{
431 .optimize_mode = .ReleaseSafe,
432 },
433 .{
434 .link_libc = true,
435 .optimize_mode = .ReleaseSafe,
436 },
437 .{
438 .optimize_mode = .ReleaseSafe,
439 .single_threaded = true,
440 },
441
442 .{
443 .optimize_mode = .ReleaseSmall,
444 },
445 .{
446 .link_libc = true,
447 .optimize_mode = .ReleaseSmall,
448 },
449 .{
450 .optimize_mode = .ReleaseSmall,
451 .single_threaded = true,
452 },
453455 };
454456};
455457
......@@ -913,8 +915,6 @@ const ModuleTestOptions = struct {
913915 skip_non_native: bool,
914916 skip_cross_glibc: bool,
915917 skip_libc: bool,
916 skip_stage1: bool,
917 skip_stage2: bool,
918918 max_rss: usize = 0,
919919};
920920
......@@ -922,49 +922,65 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
922922 const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
923923
924924 for (test_targets) |test_target| {
925 if (options.skip_non_native and !test_target.target.isNative())
925 const is_native = test_target.target.isNative() or
926 (test_target.target.getOsTag() == builtin.os.tag and
927 test_target.target.getCpuArch() == builtin.cpu.arch);
928
929 if (options.skip_non_native and !is_native)
926930 continue;
927931
928 if (options.skip_cross_glibc and test_target.target.isGnuLibC() and test_target.link_libc)
932 if (options.skip_cross_glibc and test_target.target.isGnuLibC() and test_target.link_libc == true)
929933 continue;
930934
931 if (options.skip_libc and test_target.link_libc)
935 if (options.skip_libc and test_target.link_libc == true)
932936 continue;
933937
934 if (test_target.link_libc and test_target.target.getOs().requiresLibC()) {
935 // This would be a redundant test.
938 if (options.skip_single_threaded and test_target.single_threaded == true)
936939 continue;
937 }
938940
939 if (options.skip_single_threaded and test_target.single_threaded)
941 // TODO get compiler-rt tests passing for self-hosted backends.
942 if (test_target.use_llvm == false and mem.eql(u8, options.name, "compiler-rt"))
940943 continue;
941944
942 if (test_target.disable_native and
943 test_target.target.getOsTag() == builtin.os.tag and
944 test_target.target.getCpuArch() == builtin.cpu.arch)
945 // TODO get the x86_64 self-hosted backend tests passing on Windows
946 if (test_target.target.getCpuArch() == .x86_64 and
947 test_target.target.getOsTag() == .windows and
948 test_target.use_llvm == false)
945949 {
946950 continue;
947951 }
948952
949 if (test_target.backend) |backend| switch (backend) {
950 .stage1 => if (options.skip_stage1) continue,
951 .stage2_llvm => {},
952 else => if (options.skip_stage2) continue,
953 };
953 // TODO get compiler-rt tests passing for wasm32-wasi
954 // currently causes "LLVM ERROR: Unable to expand fixed point multiplication."
955 if (test_target.target.getCpuArch() == .wasm32 and
956 test_target.target.getOsTag() == .wasi and
957 mem.eql(u8, options.name, "compiler-rt"))
958 {
959 continue;
960 }
961
962 // TODO get universal-libc tests passing for self-hosted backends.
963 if (test_target.use_llvm == false and mem.eql(u8, options.name, "universal-libc"))
964 continue;
965
966 // TODO get std lib tests passing for self-hosted backends.
967 if (test_target.use_llvm == false and mem.eql(u8, options.name, "std"))
968 continue;
969
970 // TODO get std lib tests passing for the C backend
971 if (test_target.target.ofmt == std.Target.ObjectFormat.c and
972 mem.eql(u8, options.name, "std"))
973 {
974 continue;
975 }
954976
955977 const want_this_mode = for (options.optimize_modes) |m| {
956978 if (m == test_target.optimize_mode) break true;
957979 } else false;
958980 if (!want_this_mode) continue;
959981
960 const libc_prefix = if (test_target.target.getOs().requiresLibC())
961 ""
962 else if (test_target.link_libc)
963 "c"
964 else
965 "bare";
966
967 const triple_prefix = test_target.target.zigTriple(b.allocator) catch @panic("OOM");
982 const libc_suffix = if (test_target.link_libc == true) "-libc" else "";
983 const triple_txt = test_target.target.zigTriple(b.allocator) catch @panic("OOM");
968984
969985 // wasm32-wasi builds need more RAM, idk why
970986 const max_rss = if (test_target.target.getOs().tag == .wasi)
......@@ -978,45 +994,80 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
978994 .target = test_target.target,
979995 .max_rss = max_rss,
980996 .filter = options.test_filter,
997 .link_libc = test_target.link_libc,
998 .single_threaded = test_target.single_threaded,
999 .use_llvm = test_target.use_llvm,
1000 .use_lld = test_target.use_lld,
9811001 });
982 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";
983 const backend_txt = if (test_target.backend) |backend| @tagName(backend) else "default";
984 these_tests.single_threaded = test_target.single_threaded;
985 if (test_target.link_libc) {
986 these_tests.linkSystemLibrary("c");
987 }
1002 const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else "";
1003 const backend_suffix = if (test_target.use_llvm == true)
1004 "-llvm"
1005 else if (test_target.target.ofmt == std.Target.ObjectFormat.c)
1006 "-cbe"
1007 else if (test_target.use_llvm == false)
1008 "-selfhosted"
1009 else
1010 "";
1011
9881012 these_tests.overrideZigLibDir("lib");
9891013 these_tests.addIncludePath("test");
990 if (test_target.backend) |backend| switch (backend) {
991 .stage1 => {
992 @panic("stage1 testing requested");
993 },
994 .stage2_llvm => {
995 these_tests.use_llvm = true;
996 },
997 .stage2_c => {
998 these_tests.use_llvm = false;
999 },
1000 else => {
1001 these_tests.use_llvm = false;
1002 // TODO: force self-hosted linkers to avoid LLD creeping in
1003 // until the auto-select mechanism deems them worthy
1004 these_tests.use_lld = false;
1005 },
1006 };
10071014
1008 const run = b.addRunArtifact(these_tests);
1009 run.skip_foreign_checks = true;
1010 run.setName(b.fmt("run test {s}-{s}-{s}-{s}-{s}-{s}", .{
1015 const qualified_name = b.fmt("{s}-{s}-{s}{s}{s}{s}", .{
10111016 options.name,
1012 triple_prefix,
1017 triple_txt,
10131018 @tagName(test_target.optimize_mode),
1014 libc_prefix,
1015 single_threaded_txt,
1016 backend_txt,
1017 }));
1019 libc_suffix,
1020 single_threaded_suffix,
1021 backend_suffix,
1022 });
1023
1024 if (test_target.target.ofmt == std.Target.ObjectFormat.c) {
1025 var altered_target = test_target.target;
1026 altered_target.ofmt = null;
10181027
1019 step.dependOn(&run.step);
1028 const compile_c = b.addExecutable(.{
1029 .name = qualified_name,
1030 .link_libc = test_target.link_libc,
1031 .target = altered_target,
1032 });
1033 compile_c.overrideZigLibDir("lib");
1034 compile_c.addCSourceFileSource(.{
1035 .source = these_tests.getOutputSource(),
1036 .args = &.{
1037 // TODO output -std=c89 compatible C code
1038 "-std=c99",
1039 "-pedantic",
1040 "-Werror",
1041 // TODO stop violating these pedantic errors. spotted on linux
1042 "-Wno-address-of-packed-member",
1043 "-Wno-gnu-folding-constant",
1044 "-Wno-incompatible-pointer-types",
1045 "-Wno-overlength-strings",
1046 // TODO stop violating these pedantic errors. spotted on darwin
1047 "-Wno-dollar-in-identifier-extension",
1048 "-Wno-absolute-value",
1049 },
1050 });
1051 compile_c.addIncludePath("lib"); // for zig.h
1052 if (test_target.link_libc == false and test_target.target.getOsTag() == .windows) {
1053 compile_c.subsystem = .Console;
1054 compile_c.linkSystemLibrary("kernel32");
1055 compile_c.linkSystemLibrary("ntdll");
1056 }
1057
1058 const run = b.addRunArtifact(compile_c);
1059 run.skip_foreign_checks = true;
1060 run.enableTestRunnerMode();
1061 run.setName(b.fmt("run test {s}", .{qualified_name}));
1062
1063 step.dependOn(&run.step);
1064 } else {
1065 const run = b.addRunArtifact(these_tests);
1066 run.skip_foreign_checks = true;
1067 run.setName(b.fmt("run test {s}", .{qualified_name}));
1068
1069 step.dependOn(&run.step);
1070 }
10201071 }
10211072 return step;
10221073}