| ... | ... | @@ -1927,6 +1927,7 @@ fn pollZigTest( |
| 1927 | 1927 | .ns_elapsed = if (timer) |*t| t.read() else 0, |
| 1928 | 1928 | } }; |
| 1929 | 1929 | const body = stdout.take(header.bytes_len) catch unreachable; |
| 1930 | var body_r: std.Io.Reader = .fixed(body); |
| 1930 | 1931 | switch (header.tag) { |
| 1931 | 1932 | .zig_version => { |
| 1932 | 1933 | if (!std.mem.eql(u8, builtin.zig_version_string, body)) return run.step.fail( |
| ... | ... | @@ -1942,29 +1943,23 @@ fn pollZigTest( |
| 1942 | 1943 | // restart the test runner). |
| 1943 | 1944 | assert(opt_metadata.* == null); |
| 1944 | 1945 | |
| 1945 | | const TmHdr = std.zig.Server.Message.TestMetadata; |
| 1946 | | const tm_hdr: *align(1) const TmHdr = @ptrCast(body); |
| 1946 | const tm_hdr = body_r.takeStruct(std.zig.Server.Message.TestMetadata, .little) catch unreachable; |
| 1947 | 1947 | results.test_count = tm_hdr.tests_len; |
| 1948 | 1948 | |
| 1949 | | const names_bytes = body[@sizeOf(TmHdr)..][0 .. results.test_count * @sizeOf(u32)]; |
| 1950 | | const expected_panic_msgs_bytes = body[@sizeOf(TmHdr) + names_bytes.len ..][0 .. results.test_count * @sizeOf(u32)]; |
| 1951 | | const string_bytes = body[@sizeOf(TmHdr) + names_bytes.len + expected_panic_msgs_bytes.len ..][0..tm_hdr.string_bytes_len]; |
| 1949 | const names = try arena.alloc(u32, results.test_count); |
| 1950 | for (names) |*dest| dest.* = body_r.takeInt(u32, .little) catch unreachable; |
| 1952 | 1951 | |
| 1953 | | const names = std.mem.bytesAsSlice(u32, names_bytes); |
| 1954 | | const expected_panic_msgs = std.mem.bytesAsSlice(u32, expected_panic_msgs_bytes); |
| 1952 | const expected_panic_msgs = try arena.alloc(u32, results.test_count); |
| 1953 | for (expected_panic_msgs) |*dest| dest.* = body_r.takeInt(u32, .little) catch unreachable; |
| 1955 | 1954 | |
| 1956 | | const names_aligned = try arena.alloc(u32, names.len); |
| 1957 | | for (names_aligned, names) |*dest, src| dest.* = src; |
| 1958 | | |
| 1959 | | const expected_panic_msgs_aligned = try arena.alloc(u32, expected_panic_msgs.len); |
| 1960 | | for (expected_panic_msgs_aligned, expected_panic_msgs) |*dest, src| dest.* = src; |
| 1955 | const string_bytes = body_r.take(tm_hdr.string_bytes_len) catch unreachable; |
| 1961 | 1956 | |
| 1962 | 1957 | options.progress_node.setEstimatedTotalItems(names.len); |
| 1963 | 1958 | opt_metadata.* = .{ |
| 1964 | 1959 | .string_bytes = try arena.dupe(u8, string_bytes), |
| 1965 | 1960 | .ns_per_test = try arena.alloc(u64, results.test_count), |
| 1966 | | .names = names_aligned, |
| 1967 | | .expected_panic_msgs = expected_panic_msgs_aligned, |
| 1961 | .names = names, |
| 1962 | .expected_panic_msgs = expected_panic_msgs, |
| 1968 | 1963 | .next_index = 0, |
| 1969 | 1964 | .prog_node = options.progress_node, |
| 1970 | 1965 | }; |
| ... | ... | @@ -1983,8 +1978,7 @@ fn pollZigTest( |
| 1983 | 1978 | assert(fuzz_context == null); |
| 1984 | 1979 | const md = &opt_metadata.*.?; |
| 1985 | 1980 | |
| 1986 | | const TrHdr = std.zig.Server.Message.TestResults; |
| 1987 | | const tr_hdr: *align(1) const TrHdr = @ptrCast(body); |
| 1981 | const tr_hdr = body_r.takeStruct(std.zig.Server.Message.TestResults, .little) catch unreachable; |
| 1988 | 1982 | assert(tr_hdr.index == active_test_index); |
| 1989 | 1983 | |
| 1990 | 1984 | switch (tr_hdr.flags.status) { |
| ... | ... | @@ -2026,18 +2020,21 @@ fn pollZigTest( |
| 2026 | 2020 | requestNextTest(child.stdin.?, md, &sub_prog_node) catch |err| return .{ .write_failed = err }; |
| 2027 | 2021 | }, |
| 2028 | 2022 | .coverage_id => { |
| 2029 | | const fuzz = fuzz_context.?.fuzz; |
| 2030 | | const msg_ptr: *align(1) const [4]u64 = @ptrCast(body); |
| 2031 | | coverage_id = msg_ptr[0]; |
| 2023 | coverage_id = body_r.takeInt(u64, .little) catch unreachable; |
| 2024 | const cumulative_runs = body_r.takeInt(u64, .little) catch unreachable; |
| 2025 | const cumulative_unique = body_r.takeInt(u64, .little) catch unreachable; |
| 2026 | const cumulative_coverage = body_r.takeInt(u64, .little) catch unreachable; |
| 2027 | |
| 2032 | 2028 | { |
| 2029 | const fuzz = fuzz_context.?.fuzz; |
| 2033 | 2030 | fuzz.queue_mutex.lock(); |
| 2034 | 2031 | defer fuzz.queue_mutex.unlock(); |
| 2035 | 2032 | try fuzz.msg_queue.append(fuzz.gpa, .{ .coverage = .{ |
| 2036 | 2033 | .id = coverage_id.?, |
| 2037 | 2034 | .cumulative = .{ |
| 2038 | | .runs = msg_ptr[1], |
| 2039 | | .unique = msg_ptr[2], |
| 2040 | | .coverage = msg_ptr[3], |
| 2035 | .runs = cumulative_runs, |
| 2036 | .unique = cumulative_unique, |
| 2037 | .coverage = cumulative_coverage, |
| 2041 | 2038 | }, |
| 2042 | 2039 | .run = run, |
| 2043 | 2040 | } }); |
| ... | ... | @@ -2046,8 +2043,7 @@ fn pollZigTest( |
| 2046 | 2043 | }, |
| 2047 | 2044 | .fuzz_start_addr => { |
| 2048 | 2045 | const fuzz = fuzz_context.?.fuzz; |
| 2049 | | const msg_ptr: *align(1) const u64 = @ptrCast(body); |
| 2050 | | const addr = msg_ptr.*; |
| 2046 | const addr = body_r.takeInt(u64, .little) catch unreachable; |
| 2051 | 2047 | { |
| 2052 | 2048 | fuzz.queue_mutex.lock(); |
| 2053 | 2049 | defer fuzz.queue_mutex.unlock(); |
| ... | ... | @@ -2116,7 +2112,10 @@ fn sendMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag) !void { |
| 2116 | 2112 | .tag = tag, |
| 2117 | 2113 | .bytes_len = 0, |
| 2118 | 2114 | }; |
| 2119 | | try file.writeAll(@ptrCast(&header)); |
| 2115 | var w = file.writer(&.{}); |
| 2116 | w.interface.writeStruct(header, .little) catch |err| switch (err) { |
| 2117 | error.WriteFailed => return w.err.?, |
| 2118 | }; |
| 2120 | 2119 | } |
| 2121 | 2120 | |
| 2122 | 2121 | fn sendRunTestMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag, index: u32) !void { |
| ... | ... | @@ -2124,8 +2123,13 @@ fn sendRunTestMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag, index: |
| 2124 | 2123 | .tag = tag, |
| 2125 | 2124 | .bytes_len = 4, |
| 2126 | 2125 | }; |
| 2127 | | const full_msg = std.mem.asBytes(&header) ++ std.mem.asBytes(&index); |
| 2128 | | try file.writeAll(full_msg); |
| 2126 | var w = file.writer(&.{}); |
| 2127 | w.interface.writeStruct(header, .little) catch |err| switch (err) { |
| 2128 | error.WriteFailed => return w.err.?, |
| 2129 | }; |
| 2130 | w.interface.writeInt(u32, index, .little) catch |err| switch (err) { |
| 2131 | error.WriteFailed => return w.err.?, |
| 2132 | }; |
| 2129 | 2133 | } |
| 2130 | 2134 | |
| 2131 | 2135 | fn sendRunFuzzTestMessage( |
| ... | ... | @@ -2138,10 +2142,19 @@ fn sendRunFuzzTestMessage( |
| 2138 | 2142 | .tag = .start_fuzzing, |
| 2139 | 2143 | .bytes_len = 4 + 1 + 8, |
| 2140 | 2144 | }; |
| 2141 | | const full_msg = std.mem.asBytes(&header) ++ std.mem.asBytes(&index) ++ |
| 2142 | | std.mem.asBytes(&kind) ++ std.mem.asBytes(&amount_or_instance); |
| 2143 | | |
| 2144 | | try file.writeAll(full_msg); |
| 2145 | var w = file.writer(&.{}); |
| 2146 | w.interface.writeStruct(header, .little) catch |err| switch (err) { |
| 2147 | error.WriteFailed => return w.err.?, |
| 2148 | }; |
| 2149 | w.interface.writeInt(u32, index, .little) catch |err| switch (err) { |
| 2150 | error.WriteFailed => return w.err.?, |
| 2151 | }; |
| 2152 | w.interface.writeByte(@intFromEnum(kind)) catch |err| switch (err) { |
| 2153 | error.WriteFailed => return w.err.?, |
| 2154 | }; |
| 2155 | w.interface.writeInt(u64, amount_or_instance, .little) catch |err| switch (err) { |
| 2156 | error.WriteFailed => return w.err.?, |
| 2157 | }; |
| 2145 | 2158 | } |
| 2146 | 2159 | |
| 2147 | 2160 | fn evalGeneric(run: *Run, child: *std.process.Child) !EvalGenericResult { |