Skip to content

Commit

Permalink
Add --duration and --blind to ZestCLI
Browse files Browse the repository at this point in the history
  • Loading branch information
vlsi committed Jan 18, 2020
1 parent e195218 commit feb3622
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions fuzz/src/main/java/edu/berkeley/cs/jqf/fuzz/ei/ZestCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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")) {
Expand All @@ -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);
}
}

0 comments on commit feb3622

Please sign in to comment.