diff --git a/fuzz/src/main/java/edu/berkeley/cs/jqf/fuzz/ei/ZestCLI.java b/fuzz/src/main/java/edu/berkeley/cs/jqf/fuzz/ei/ZestCLI.java index 4a9f5fbaa..6a50d1461 100644 --- a/fuzz/src/main/java/edu/berkeley/cs/jqf/fuzz/ei/ZestCLI.java +++ b/fuzz/src/main/java/edu/berkeley/cs/jqf/fuzz/ei/ZestCLI.java @@ -38,6 +38,8 @@ import picocli.CommandLine.Parameters; import java.io.File; +import java.time.Duration; +import java.time.format.DateTimeParseException; import java.util.ArrayList; /** @@ -73,6 +75,14 @@ static class Dependent { description = "Output Directory containing results (default: fuzz_results)") private File outputDirectory = new File("fuzz-results"); + @Option(names = { "-d", "--duration" }, + description = "Total fuzz duration (e.g. PT5s or 5s)") + private Duration duration; + + @Option(names = { "-b", "--blind" }, + description = "Blind fuzzing: do not use coverage feedback (default: false)") + private boolean blindFuzzing; + @Parameters(index = "0", paramLabel = "PACKAGE", description = "package containing the fuzz target and all dependencies") private String testPackageName; @@ -130,9 +140,9 @@ public void run() { // Load the guidance String title = this.testClassName+"#"+this.testMethodName; ZestGuidance guidance = seedFiles.length > 0 ? - new ZestGuidance(title, null, this.outputDirectory, seedFiles) : - new ZestGuidance(title, null, this.outputDirectory); - + new ZestGuidance(title, duration, this.outputDirectory, seedFiles) : + new ZestGuidance(title, duration, this.outputDirectory); + guidance.setBlind(blindFuzzing); // Run the Junit test Result res = GuidedFuzzing.run(testClassName, testMethodName, loader, guidance, System.out); if (Boolean.getBoolean("jqf.logCoverage")) { @@ -150,7 +160,15 @@ public void run() { } public static void main(String[] args) { - int exitCode = new CommandLine(new ZestCLI()).execute(args); + int exitCode = new CommandLine(new ZestCLI()) + .registerConverter(Duration.class, v -> { + try { + return Duration.parse(v); + } catch (DateTimeParseException e) { + return Duration.parse("PT" + v); + } + }) + .execute(args); System.exit(exitCode); } }