mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-06 07:38:21 +00:00
pkg/afl++: extract runner
This commit is contained in:
@@ -30,6 +30,30 @@ pub fn addInstrumentedExe(
|
||||
return fuzz_exe;
|
||||
}
|
||||
|
||||
/// Creates a run step that invokes `afl-fuzz` with the given instrumented
|
||||
/// executable, input corpus directory, and output directory.
|
||||
///
|
||||
/// Returns the `Run` step so callers can wire it into a build step.
|
||||
pub fn addFuzzerRun(
|
||||
b: *std.Build,
|
||||
exe: std.Build.LazyPath,
|
||||
corpus_dir: std.Build.LazyPath,
|
||||
output_dir: std.Build.LazyPath,
|
||||
) *std.Build.Step.Run {
|
||||
const run = b.addSystemCommand(&.{
|
||||
b.findProgram(&.{"afl-fuzz"}, &.{}) catch
|
||||
@panic("Could not find 'afl-fuzz', which is required to run"),
|
||||
"-i",
|
||||
});
|
||||
run.addDirectoryArg(corpus_dir);
|
||||
run.addArgs(&.{"-o"});
|
||||
run.addDirectoryArg(output_dir);
|
||||
run.addArgs(&.{"--"});
|
||||
run.addFileArg(exe);
|
||||
run.addArgs(&.{"@@"});
|
||||
return run;
|
||||
}
|
||||
|
||||
// Required so `zig build` works although it does nothing.
|
||||
pub fn build(b: *std.Build) !void {
|
||||
_ = b;
|
||||
|
||||
@@ -44,20 +44,7 @@ pub fn build(b: *std.Build) void {
|
||||
const exe = afl.addInstrumentedExe(b, lib);
|
||||
|
||||
// Runner to simplify running afl-fuzz
|
||||
const run = run: {
|
||||
const run = b.addSystemCommand(&.{
|
||||
b.findProgram(&.{"afl-fuzz"}, &.{}) catch
|
||||
@panic("Could not find 'afl-fuzz', which is required to run"),
|
||||
"-i",
|
||||
});
|
||||
run.addDirectoryArg(b.path("corpus/initial"));
|
||||
run.addArgs(&.{"-o"});
|
||||
run.addDirectoryArg(b.path("afl-out"));
|
||||
run.addArgs(&.{"--"});
|
||||
run.addFileArg(exe);
|
||||
run.addArgs(&.{"@@"});
|
||||
break :run run;
|
||||
};
|
||||
const run = afl.addFuzzerRun(b, exe, b.path("corpus/initial"), b.path("afl-out"));
|
||||
|
||||
// Install
|
||||
b.installArtifact(lib);
|
||||
|
||||
Reference in New Issue
Block a user