| ... | ... | @@ -14,7 +14,7 @@ const CrossTarget = std.zig.CrossTarget; |
| 14 | 14 | |
| 15 | 15 | const zig_h = link.File.C.zig_h; |
| 16 | 16 | |
| 17 | | const hr = "=" ** 40; |
| 17 | const hr = "=" ** 80; |
| 18 | 18 | |
| 19 | 19 | test "self-hosted" { |
| 20 | 20 | var ctx = TestContext.init(); |
| ... | ... | @@ -541,6 +541,8 @@ pub const TestContext = struct { |
| 541 | 541 | }; |
| 542 | 542 | defer std.testing.allocator.free(global_cache_directory.path.?); |
| 543 | 543 | |
| 544 | var fail_count: usize = 0; |
| 545 | |
| 544 | 546 | for (self.cases.items) |case| { |
| 545 | 547 | if (build_options.skip_non_native and case.target.getCpuArch() != std.Target.current.cpu.arch) |
| 546 | 548 | continue; |
| ... | ... | @@ -558,14 +560,21 @@ pub const TestContext = struct { |
| 558 | 560 | progress.initial_delay_ns = 0; |
| 559 | 561 | progress.refresh_rate_ns = 0; |
| 560 | 562 | |
| 561 | | try self.runOneCase( |
| 563 | self.runOneCase( |
| 562 | 564 | std.testing.allocator, |
| 563 | 565 | &prg_node, |
| 564 | 566 | case, |
| 565 | 567 | zig_lib_directory, |
| 566 | 568 | &thread_pool, |
| 567 | 569 | global_cache_directory, |
| 568 | | ); |
| 570 | ) catch |err| { |
| 571 | fail_count += 1; |
| 572 | std.debug.print("test '{s}' failed: {s}\n\n", .{ case.name, @errorName(err) }); |
| 573 | }; |
| 574 | } |
| 575 | if (fail_count != 0) { |
| 576 | std.debug.print("{d} tests failed\n", .{fail_count}); |
| 577 | return error.TestFailed; |
| 569 | 578 | } |
| 570 | 579 | } |
| 571 | 580 | |
| ... | ... | @@ -693,8 +702,7 @@ pub const TestContext = struct { |
| 693 | 702 | } |
| 694 | 703 | } |
| 695 | 704 | // TODO print generated C code |
| 696 | | std.debug.print("Test failed.\n", .{}); |
| 697 | | std.process.exit(1); |
| 705 | return error.UnexpectedCompileErrors; |
| 698 | 706 | } |
| 699 | 707 | } |
| 700 | 708 | |
| ... | ... | @@ -817,10 +825,8 @@ pub const TestContext = struct { |
| 817 | 825 | } |
| 818 | 826 | |
| 819 | 827 | if (any_failed) { |
| 820 | | std.debug.print("\nTest case '{s}' failed, update_index={d}.\n", .{ |
| 821 | | case.name, update_index, |
| 822 | | }); |
| 823 | | std.process.exit(1); |
| 828 | std.debug.print("\nupdate_index={d} ", .{update_index}); |
| 829 | return error.WrongCompileErrors; |
| 824 | 830 | } |
| 825 | 831 | }, |
| 826 | 832 | .Execution => |expected_stdout| { |
| ... | ... | @@ -908,11 +914,11 @@ pub const TestContext = struct { |
| 908 | 914 | .cwd_dir = tmp.dir, |
| 909 | 915 | .cwd = tmp_dir_path, |
| 910 | 916 | }) catch |err| { |
| 911 | | std.debug.print("\nThe following command failed with {s}:\n", .{ |
| 912 | | @errorName(err), |
| 917 | std.debug.print("\nupdate_index={d} The following command failed with {s}:\n", .{ |
| 918 | update_index, @errorName(err), |
| 913 | 919 | }); |
| 914 | 920 | dumpArgs(argv.items); |
| 915 | | return error.ZigTestFailed; |
| 921 | return error.ChildProcessExecution; |
| 916 | 922 | }; |
| 917 | 923 | }; |
| 918 | 924 | var test_node = update_node.start("test", 0); |
| ... | ... | @@ -927,7 +933,7 @@ pub const TestContext = struct { |
| 927 | 933 | exec_result.stderr, case.name, code, |
| 928 | 934 | }); |
| 929 | 935 | dumpArgs(argv.items); |
| 930 | | return error.ZigTestFailed; |
| 936 | return error.ChildProcessExecution; |
| 931 | 937 | } |
| 932 | 938 | }, |
| 933 | 939 | else => { |
| ... | ... | @@ -935,7 +941,7 @@ pub const TestContext = struct { |
| 935 | 941 | exec_result.stderr, case.name, |
| 936 | 942 | }); |
| 937 | 943 | dumpArgs(argv.items); |
| 938 | | return error.ZigTestFailed; |
| 944 | return error.ChildProcessExecution; |
| 939 | 945 | }, |
| 940 | 946 | } |
| 941 | 947 | try std.testing.expectEqualStrings(expected_stdout, exec_result.stdout); |
| ... | ... | @@ -1016,26 +1022,26 @@ pub const TestContext = struct { |
| 1016 | 1022 | while (try iterator.next()) |phdr| { |
| 1017 | 1023 | if (phdr.p_type != std.elf.PT_LOAD) { |
| 1018 | 1024 | std.debug.print("Encountered unexpected ELF program header: type {}\n", .{phdr.p_type}); |
| 1019 | | std.process.exit(1); |
| 1025 | return error.UnexpectedElfProgramHeader; |
| 1020 | 1026 | } |
| 1021 | 1027 | if (phdr.p_paddr != phdr.p_vaddr) { |
| 1022 | 1028 | std.debug.print("Physical address does not match virtual address in ELF header!\n", .{}); |
| 1023 | | std.process.exit(1); |
| 1029 | return error.PhysicalAddressMismatchVirt; |
| 1024 | 1030 | } |
| 1025 | 1031 | if (phdr.p_filesz != phdr.p_memsz) { |
| 1026 | 1032 | std.debug.print("Physical size does not match virtual size in ELF header!\n", .{}); |
| 1027 | | std.process.exit(1); |
| 1033 | return error.PhysicalSizeMismatchVirt; |
| 1028 | 1034 | } |
| 1029 | 1035 | if ((try file.pread(interpreter.bus.RAM[phdr.p_paddr .. phdr.p_paddr + phdr.p_filesz], phdr.p_offset)) != phdr.p_filesz) { |
| 1030 | 1036 | std.debug.print("Read less than expected from ELF file!", .{}); |
| 1031 | | std.process.exit(1); |
| 1037 | return error.ElfFileEof; |
| 1032 | 1038 | } |
| 1033 | 1039 | std.log.scoped(.spu2_test).debug("Loaded 0x{x} bytes to 0x{x:0<4}\n", .{ phdr.p_filesz, phdr.p_paddr }); |
| 1034 | 1040 | none_loaded = false; |
| 1035 | 1041 | } |
| 1036 | 1042 | if (none_loaded) { |
| 1037 | 1043 | std.debug.print("No data found in ELF file!\n", .{}); |
| 1038 | | std.process.exit(1); |
| 1044 | return error.EmptyElfFile; |
| 1039 | 1045 | } |
| 1040 | 1046 | } |
| 1041 | 1047 | |
| ... | ... | @@ -1052,7 +1058,7 @@ pub const TestContext = struct { |
| 1052 | 1058 | try interpreter.ExecuteBlock(block_size); |
| 1053 | 1059 | if (pre_ip == interpreter.ip) { |
| 1054 | 1060 | std.debug.print("Infinite loop detected in SPU II test!\n", .{}); |
| 1055 | | std.process.exit(1); |
| 1061 | return error.InfiniteLoop; |
| 1056 | 1062 | } |
| 1057 | 1063 | } |
| 1058 | 1064 | } |