| ... | @@ -88,9 +88,10 @@ dep_output_file: ?*Output, | ... | @@ -88,9 +88,10 @@ dep_output_file: ?*Output, |
| 88 | | 88 | |
| 89 | has_side_effects: bool, | 89 | has_side_effects: bool, |
| 90 | | 90 | |
| 91 | /// If this is a Zig unit test binary, this tracks the indexes of the unit | 91 | /// If this is a Zig unit test binary, this tracks the names of the unit |
| 92 | /// tests that are also fuzz tests. | 92 | /// tests that are also fuzz tests. Indexes cannot be used as they may |
| 93 | fuzz_tests: std.ArrayList(u32), | 93 | /// change between reruns. |
| | 94 | fuzz_tests: std.ArrayList([]const u8), |
| 94 | cached_test_metadata: ?CachedTestMetadata = null, | 95 | cached_test_metadata: ?CachedTestMetadata = null, |
| 95 | | 96 | |
| 96 | /// Populated during the fuzz phase if this run step corresponds to a unit test | 97 | /// Populated during the fuzz phase if this run step corresponds to a unit test |
| ... | @@ -1067,7 +1068,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { | ... | @@ -1067,7 +1068,7 @@ fn make(step: *Step, options: Step.MakeOptions) !void { |
| 1067 | pub fn rerunInFuzzMode( | 1068 | pub fn rerunInFuzzMode( |
| 1068 | run: *Run, | 1069 | run: *Run, |
| 1069 | fuzz: *std.Build.Fuzz, | 1070 | fuzz: *std.Build.Fuzz, |
| 1070 | unit_test_index: u32, | 1071 | unit_test_name: []const u8, |
| 1071 | prog_node: std.Progress.Node, | 1072 | prog_node: std.Progress.Node, |
| 1072 | ) !void { | 1073 | ) !void { |
| 1073 | const step = &run.step; | 1074 | const step = &run.step; |
| ... | @@ -1138,7 +1139,7 @@ pub fn rerunInFuzzMode( | ... | @@ -1138,7 +1139,7 @@ pub fn rerunInFuzzMode( |
| 1138 | .unit_test_timeout_ns = null, // don't time out fuzz tests for now | 1139 | .unit_test_timeout_ns = null, // don't time out fuzz tests for now |
| 1139 | .gpa = fuzz.gpa, | 1140 | .gpa = fuzz.gpa, |
| 1140 | }, .{ | 1141 | }, .{ |
| 1141 | .unit_test_index = unit_test_index, | 1142 | .unit_test_name = unit_test_name, |
| 1142 | .fuzz = fuzz, | 1143 | .fuzz = fuzz, |
| 1143 | }); | 1144 | }); |
| 1144 | } | 1145 | } |
| ... | @@ -1210,7 +1211,7 @@ fn termMatches(expected: ?process.Child.Term, actual: process.Child.Term) bool { | ... | @@ -1210,7 +1211,7 @@ fn termMatches(expected: ?process.Child.Term, actual: process.Child.Term) bool { |
| 1210 | | 1211 | |
| 1211 | const FuzzContext = struct { | 1212 | const FuzzContext = struct { |
| 1212 | fuzz: *std.Build.Fuzz, | 1213 | fuzz: *std.Build.Fuzz, |
| 1213 | unit_test_index: u32, | 1214 | unit_test_name: []const u8, |
| 1214 | }; | 1215 | }; |
| 1215 | | 1216 | |
| 1216 | fn runCommand( | 1217 | fn runCommand( |
| ... | @@ -1843,7 +1844,7 @@ fn waitZigTest( | ... | @@ -1843,7 +1844,7 @@ fn waitZigTest( |
| 1843 | sendRunFuzzTestMessage( | 1844 | sendRunFuzzTestMessage( |
| 1844 | io, | 1845 | io, |
| 1845 | child.stdin.?, | 1846 | child.stdin.?, |
| 1846 | ctx.unit_test_index, | 1847 | ctx.unit_test_name, |
| 1847 | .forever, | 1848 | .forever, |
| 1848 | 0, // instance ID; will be used by multiprocess forever fuzzing in the future | 1849 | 0, // instance ID; will be used by multiprocess forever fuzzing in the future |
| 1849 | ) catch |err| return .{ .write_failed = err }; | 1850 | ) catch |err| return .{ .write_failed = err }; |
| ... | @@ -1852,7 +1853,7 @@ fn waitZigTest( | ... | @@ -1852,7 +1853,7 @@ fn waitZigTest( |
| 1852 | sendRunFuzzTestMessage( | 1853 | sendRunFuzzTestMessage( |
| 1853 | io, | 1854 | io, |
| 1854 | child.stdin.?, | 1855 | child.stdin.?, |
| 1855 | ctx.unit_test_index, | 1856 | ctx.unit_test_name, |
| 1856 | .iterations, | 1857 | .iterations, |
| 1857 | limit.amount, | 1858 | limit.amount, |
| 1858 | ) catch |err| return .{ .write_failed = err }; | 1859 | ) catch |err| return .{ .write_failed = err }; |
| ... | @@ -2001,10 +2002,10 @@ fn waitZigTest( | ... | @@ -2001,10 +2002,10 @@ fn waitZigTest( |
| 2001 | results.leak_count +|= leak_count; | 2002 | results.leak_count +|= leak_count; |
| 2002 | results.log_err_count +|= log_err_count; | 2003 | results.log_err_count +|= log_err_count; |
| 2003 | | 2004 | |
| 2004 | if (tr_hdr.flags.fuzz) try run.fuzz_tests.append(gpa, tr_hdr.index); | 2005 | if (tr_hdr.flags.fuzz) try run.fuzz_tests.append(gpa, md.testName(tr_hdr.index)); |
| 2005 | | 2006 | |
| 2006 | if (tr_hdr.flags.status == .fail) { | 2007 | if (tr_hdr.flags.status == .fail) { |
| 2007 | const name = std.mem.sliceTo(md.testName(tr_hdr.index), 0); | 2008 | const name = md.testName(tr_hdr.index); |
| 2008 | const stderr_bytes = std.mem.trim(u8, stderr.buffered(), "\n"); | 2009 | const stderr_bytes = std.mem.trim(u8, stderr.buffered(), "\n"); |
| 2009 | stderr.tossBuffered(); | 2010 | stderr.tossBuffered(); |
| 2010 | if (stderr_bytes.len == 0) { | 2011 | if (stderr_bytes.len == 0) { |
| ... | @@ -2013,12 +2014,12 @@ fn waitZigTest( | ... | @@ -2013,12 +2014,12 @@ fn waitZigTest( |
| 2013 | try run.step.addError("'{s}' failed:\n{s}", .{ name, stderr_bytes }); | 2014 | try run.step.addError("'{s}' failed:\n{s}", .{ name, stderr_bytes }); |
| 2014 | } | 2015 | } |
| 2015 | } else if (leak_count > 0) { | 2016 | } else if (leak_count > 0) { |
| 2016 | const name = std.mem.sliceTo(md.testName(tr_hdr.index), 0); | 2017 | const name = md.testName(tr_hdr.index); |
| 2017 | const stderr_bytes = std.mem.trim(u8, stderr.buffered(), "\n"); | 2018 | const stderr_bytes = std.mem.trim(u8, stderr.buffered(), "\n"); |
| 2018 | stderr.tossBuffered(); | 2019 | stderr.tossBuffered(); |
| 2019 | try run.step.addError("'{s}' leaked {d} allocations:\n{s}", .{ name, leak_count, stderr_bytes }); | 2020 | try run.step.addError("'{s}' leaked {d} allocations:\n{s}", .{ name, leak_count, stderr_bytes }); |
| 2020 | } else if (log_err_count > 0) { | 2021 | } else if (log_err_count > 0) { |
| 2021 | const name = std.mem.sliceTo(md.testName(tr_hdr.index), 0); | 2022 | const name = md.testName(tr_hdr.index); |
| 2022 | const stderr_bytes = std.mem.trim(u8, stderr.buffered(), "\n"); | 2023 | const stderr_bytes = std.mem.trim(u8, stderr.buffered(), "\n"); |
| 2023 | stderr.tossBuffered(); | 2024 | stderr.tossBuffered(); |
| 2024 | try run.step.addError("'{s}' logged {d} errors:\n{s}", .{ name, log_err_count, stderr_bytes }); | 2025 | try run.step.addError("'{s}' logged {d} errors:\n{s}", .{ name, log_err_count, stderr_bytes }); |
| ... | @@ -2148,7 +2149,7 @@ fn sendRunTestMessage(io: Io, file: Io.File, tag: std.zig.Client.Message.Tag, in | ... | @@ -2148,7 +2149,7 @@ fn sendRunTestMessage(io: Io, file: Io.File, tag: std.zig.Client.Message.Tag, in |
| 2148 | fn sendRunFuzzTestMessage( | 2149 | fn sendRunFuzzTestMessage( |
| 2149 | io: Io, | 2150 | io: Io, |
| 2150 | file: Io.File, | 2151 | file: Io.File, |
| 2151 | index: u32, | 2152 | test_name: []const u8, |
| 2152 | kind: std.Build.abi.fuzz.LimitKind, | 2153 | kind: std.Build.abi.fuzz.LimitKind, |
| 2153 | amount_or_instance: u64, | 2154 | amount_or_instance: u64, |
| 2154 | ) !void { | 2155 | ) !void { |
| ... | @@ -2160,7 +2161,10 @@ fn sendRunFuzzTestMessage( | ... | @@ -2160,7 +2161,10 @@ fn sendRunFuzzTestMessage( |
| 2160 | w.interface.writeStruct(header, .little) catch |err| switch (err) { | 2161 | w.interface.writeStruct(header, .little) catch |err| switch (err) { |
| 2161 | error.WriteFailed => return w.err.?, | 2162 | error.WriteFailed => return w.err.?, |
| 2162 | }; | 2163 | }; |
| 2163 | w.interface.writeInt(u32, index, .little) catch |err| switch (err) { | 2164 | w.interface.writeInt(u32, @intCast(test_name.len), .little) catch |err| switch (err) { |
| | 2165 | error.WriteFailed => return w.err.?, |
| | 2166 | }; |
| | 2167 | w.interface.writeAll(test_name) catch |err| switch (err) { |
| 2164 | error.WriteFailed => return w.err.?, | 2168 | error.WriteFailed => return w.err.?, |
| 2165 | }; | 2169 | }; |
| 2166 | w.interface.writeByte(@intFromEnum(kind)) catch |err| switch (err) { | 2170 | w.interface.writeByte(@intFromEnum(kind)) catch |err| switch (err) { |