mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
fuzzer web ui: add coverage stat
This commit is contained in:
parent
f56d113503
commit
6e6164f8a6
@ -129,6 +129,7 @@
|
||||
<ul>
|
||||
<li>Total Runs: <span id="statTotalRuns"></span></li>
|
||||
<li>Unique Runs: <span id="statUniqueRuns"></span></li>
|
||||
<li>Coverage: <span id="statCoverage"></span></li>
|
||||
<li>Lowest Stack: <span id="statLowestStack"></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
const domSourceText = document.getElementById("sourceText");
|
||||
const domStatTotalRuns = document.getElementById("statTotalRuns");
|
||||
const domStatUniqueRuns = document.getElementById("statUniqueRuns");
|
||||
const domStatCoverage = document.getElementById("statCoverage");
|
||||
const domStatLowestStack = document.getElementById("statLowestStack");
|
||||
|
||||
let wasm_promise = fetch("main.wasm");
|
||||
@ -112,8 +113,11 @@
|
||||
function renderStats() {
|
||||
const totalRuns = wasm_exports.totalRuns();
|
||||
const uniqueRuns = wasm_exports.uniqueRuns();
|
||||
const totalSourceLocations = wasm_exports.totalSourceLocations();
|
||||
const coveredSourceLocations = wasm_exports.coveredSourceLocations();
|
||||
domStatTotalRuns.innerText = totalRuns;
|
||||
domStatUniqueRuns.innerText = uniqueRuns + " (" + percent(uniqueRuns, totalRuns) + "%)";
|
||||
domStatCoverage.innerText = coveredSourceLocations + " / " + totalSourceLocations + " (" + percent(coveredSourceLocations, totalSourceLocations) + "%)";
|
||||
domStatLowestStack.innerText = unwrapString(wasm_exports.lowestStack());
|
||||
|
||||
domSectStats.classList.remove("hidden");
|
||||
|
||||
@ -110,6 +110,17 @@ export fn lowestStack() String {
|
||||
return String.init(string_result.items);
|
||||
}
|
||||
|
||||
export fn totalSourceLocations() usize {
|
||||
return coverage_source_locations.items.len;
|
||||
}
|
||||
|
||||
export fn coveredSourceLocations() usize {
|
||||
const covered_bits = recent_coverage_update.items[@sizeOf(abi.CoverageUpdateHeader)..];
|
||||
var count: usize = 0;
|
||||
for (covered_bits) |byte| count += @popCount(byte);
|
||||
return count;
|
||||
}
|
||||
|
||||
export fn totalRuns() u64 {
|
||||
const header: *abi.CoverageUpdateHeader = @ptrCast(recent_coverage_update.items[0..@sizeOf(abi.CoverageUpdateHeader)]);
|
||||
return header.n_runs;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user