| author | |
| committer | |
| log | 1a9d75ebe0037bd908ed263bb7f4228f9a8681ef |
| tree | 5570585f73d01633a9100c557da8bd166ec56fee |
| parent | af1e196db3bca66c29979c685b1c9c896c275211 |
3 files changed, 8 insertions(+), 1 deletions(-)
lib/build-web/fuzz.zig+3-1| ... | @@ -1,5 +1,6 @@ | ... | @@ -1,5 +1,6 @@ |
| 1 | // Server timestamp. | 1 | // Server timestamp. |
| 2 | var start_fuzzing_timestamp: i64 = undefined; | 2 | var start_fuzzing_timestamp: i64 = undefined; |
| 3 | var start_fuzzing_n_runs: u64 = undefined; | ||
| 3 | 4 | ||
| 4 | const js = struct { | 5 | const js = struct { |
| 5 | extern "fuzz" fn requestSources() void; | 6 | extern "fuzz" fn requestSources() void; |
| ... | @@ -36,6 +37,7 @@ pub fn sourceIndexMessage(msg_bytes: []u8) error{OutOfMemory}!void { | ... | @@ -36,6 +37,7 @@ pub fn sourceIndexMessage(msg_bytes: []u8) error{OutOfMemory}!void { |
| 36 | const source_locations: []const Coverage.SourceLocation = @alignCast(std.mem.bytesAsSlice(Coverage.SourceLocation, msg_bytes[source_locations_start..source_locations_end])); | 37 | const source_locations: []const Coverage.SourceLocation = @alignCast(std.mem.bytesAsSlice(Coverage.SourceLocation, msg_bytes[source_locations_start..source_locations_end])); |
| 37 | 38 | ||
| 38 | start_fuzzing_timestamp = header.start_timestamp; | 39 | start_fuzzing_timestamp = header.start_timestamp; |
| 40 | start_fuzzing_n_runs = header.start_n_runs; | ||
| 39 | try updateCoverageSources(directories, files, source_locations, string_bytes); | 41 | try updateCoverageSources(directories, files, source_locations, string_bytes); |
| 40 | js.ready(); | 42 | js.ready(); |
| 41 | } | 43 | } |
| ... | @@ -271,7 +273,7 @@ fn updateStats() error{OutOfMemory}!void { | ... | @@ -271,7 +273,7 @@ fn updateStats() error{OutOfMemory}!void { |
| 271 | 273 | ||
| 272 | const avg_speed: f64 = speed: { | 274 | const avg_speed: f64 = speed: { |
| 273 | const ns_elapsed: f64 = @floatFromInt(nsSince(start_fuzzing_timestamp)); | 275 | const ns_elapsed: f64 = @floatFromInt(nsSince(start_fuzzing_timestamp)); |
| 274 | const n_runs: f64 = @floatFromInt(hdr.n_runs); | 276 | const n_runs: f64 = @floatFromInt(hdr.n_runs -% start_fuzzing_n_runs); |
| 275 | break :speed n_runs / (ns_elapsed / std.time.ns_per_s); | 277 | break :speed n_runs / (ns_elapsed / std.time.ns_per_s); |
| 276 | }; | 278 | }; |
| 277 | 279 |
lib/std/Build/Fuzz.zig+4| ... | @@ -64,6 +64,7 @@ const CoverageMap = struct { | ... | @@ -64,6 +64,7 @@ const CoverageMap = struct { |
| 64 | /// Elements are indexes into `source_locations` pointing to the unit tests that are being fuzz tested. | 64 | /// Elements are indexes into `source_locations` pointing to the unit tests that are being fuzz tested. |
| 65 | entry_points: std.ArrayList(u32), | 65 | entry_points: std.ArrayList(u32), |
| 66 | start_timestamp: i64, | 66 | start_timestamp: i64, |
| 67 | start_n_runs: u64, | ||
| 67 | 68 | ||
| 68 | fn deinit(cm: *CoverageMap, gpa: Allocator) void { | 69 | fn deinit(cm: *CoverageMap, gpa: Allocator) void { |
| 69 | std.posix.munmap(cm.mapped_memory); | 70 | std.posix.munmap(cm.mapped_memory); |
| ... | @@ -299,6 +300,7 @@ pub fn sendUpdate( | ... | @@ -299,6 +300,7 @@ pub fn sendUpdate( |
| 299 | .source_locations_len = @intCast(coverage_map.source_locations.len), | 300 | .source_locations_len = @intCast(coverage_map.source_locations.len), |
| 300 | .string_bytes_len = @intCast(coverage_map.coverage.string_bytes.items.len), | 301 | .string_bytes_len = @intCast(coverage_map.coverage.string_bytes.items.len), |
| 301 | .start_timestamp = coverage_map.start_timestamp, | 302 | .start_timestamp = coverage_map.start_timestamp, |
| 303 | .start_n_runs = coverage_map.start_n_runs, | ||
| 302 | }; | 304 | }; |
| 303 | var iovecs: [5][]const u8 = .{ | 305 | var iovecs: [5][]const u8 = .{ |
| 304 | @ptrCast(&header), | 306 | @ptrCast(&header), |
| ... | @@ -390,6 +392,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO | ... | @@ -390,6 +392,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO |
| 390 | .source_locations = undefined, // populated below | 392 | .source_locations = undefined, // populated below |
| 391 | .entry_points = .{}, | 393 | .entry_points = .{}, |
| 392 | .start_timestamp = ws.now(), | 394 | .start_timestamp = ws.now(), |
| 395 | .start_n_runs = undefined, // populated below | ||
| 393 | }; | 396 | }; |
| 394 | errdefer gop.value_ptr.coverage.deinit(gpa); | 397 | errdefer gop.value_ptr.coverage.deinit(gpa); |
| 395 | 398 | ||
| ... | @@ -467,6 +470,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO | ... | @@ -467,6 +470,7 @@ fn prepareTables(fuzz: *Fuzz, run_step: *Step.Run, coverage_id: u64) error{ OutO |
| 467 | 470 | ||
| 468 | for (sorted_pcs.items(.index), sorted_pcs.items(.sl)) |i, sl| source_locations[i] = sl; | 471 | for (sorted_pcs.items(.index), sorted_pcs.items(.sl)) |i, sl| source_locations[i] = sl; |
| 469 | gop.value_ptr.source_locations = source_locations; | 472 | gop.value_ptr.source_locations = source_locations; |
| 473 | gop.value_ptr.start_n_runs = header.n_runs; | ||
| 470 | 474 | ||
| 471 | ws.notifyUpdate(); | 475 | ws.notifyUpdate(); |
| 472 | } | 476 | } |
lib/std/Build/abi.zig+1| ... | @@ -219,6 +219,7 @@ pub const fuzz = struct { | ... | @@ -219,6 +219,7 @@ pub const fuzz = struct { |
| 219 | string_bytes_len: u32, | 219 | string_bytes_len: u32, |
| 220 | /// When, according to the server, fuzzing started. | 220 | /// When, according to the server, fuzzing started. |
| 221 | start_timestamp: i64 align(4), | 221 | start_timestamp: i64 align(4), |
| 222 | start_n_runs: u64 align(4), | ||
| 222 | }; | 223 | }; |
| 223 | 224 | ||
| 224 | /// WebSocket server->client. | 225 | /// WebSocket server->client. |