Skip to content

Commit

Permalink
✨ Fix timeout -> runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
lukacan committed Jan 12, 2025
1 parent 01e560e commit a9316e6
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 23 deletions.
16 changes: 9 additions & 7 deletions crates/config/src/afl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct Afl {
pub iterations: Option<u64>,
// seconds
// -V
pub timeout: Option<u64>,
pub run_time: Option<u64>,
// seeds
// -s
pub seeds: Option<Vec<AflSeed>>,
Expand Down Expand Up @@ -52,13 +52,15 @@ impl Afl {
// execs
self.iterations
.as_ref()
.filter(|&iterations| *iterations > 0)
.map(|iterations| Argument::new("-E", "", Some(&iterations.to_string())))
}
pub fn get_timeout(&self) -> Option<Argument> {
pub fn get_run_time(&self) -> Option<Argument> {
// seconds
self.timeout
self.run_time
.as_ref()
.map(|timeout| Argument::new("-V", "", Some(&timeout.to_string())))
.filter(|&run_time| *run_time > 0)
.map(|run_time| Argument::new("-V", "", Some(&run_time.to_string())))
}
pub fn get_seeds(&self) -> Vec<AflSeed> {
// seeds
Expand All @@ -80,7 +82,7 @@ impl Afl {
if let Some(execs) = self.get_iterations() {
result.extend(arg_to_string(&execs));
}
if let Some(seconds) = self.get_timeout() {
if let Some(seconds) = self.get_run_time() {
result.extend(arg_to_string(&seconds));
}
result
Expand Down Expand Up @@ -117,7 +119,7 @@ mod tests {
afl_workspace_in: None,
afl_workspace_out: None,
iterations: None,
timeout: None,
run_time: None,
seeds: None,
}
}
Expand Down Expand Up @@ -169,7 +171,7 @@ mod tests {
let mut afl = Afl::clean();

// seconds
afl.timeout = Some(15);
afl.run_time = Some(15);

let arg = afl.get_collect_fuzz_args();
assert_eq!(arg, vec!["-V", "15"]);
Expand Down
4 changes: 2 additions & 2 deletions crates/config/template/Trident.toml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ fuzzing_with_stats = true

[honggfuzz]
iterations = 10000
timeout = 20
run_time = 20
exit_upon_crash = true

[afl]
iterations = 10000
timeout = 20
run_time = 20
4 changes: 2 additions & 2 deletions examples/common_issues/arbitrary-limit-inputs-5/Trident.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ fuzzing_with_stats = true

[honggfuzz]
iterations = 100
timeout = 20
run_time = 20
exit_upon_crash = false
# threads = 1
# keep_output = true
# verbose = true

[afl]
iterations = 10000
timeout = 20
run_time = 20
4 changes: 2 additions & 2 deletions examples/common_issues/incorrect-ix-sequence-1/Trident.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ fuzzing_with_stats = true

[honggfuzz]
iterations = 10000
timeout = 20
run_time = 20
exit_upon_crash = true

[afl]
iterations = 10000
timeout = 20
run_time = 20
4 changes: 2 additions & 2 deletions examples/common_issues/unchecked-arithmetic-0/Trident.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ fuzzing_with_stats = true

[honggfuzz]
iterations = 10000
timeout = 20
run_time = 20
exit_upon_crash = true

[afl]
iterations = 10000
timeout = 20
run_time = 20
4 changes: 2 additions & 2 deletions examples/cpi/cpi-metaplex-7/Trident.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ program = "metaplex-program/metaplex-token-metadata.so"

[honggfuzz]
iterations = 10000
timeout = 20
run_time = 20
exit_upon_crash = true

[afl]
iterations = 1000
timeout = 20
run_time = 20

[[afl.seeds]]
file_name = "custom-seed"
Expand Down
4 changes: 2 additions & 2 deletions examples/cpi/simple-cpi-6/Trident.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ fuzzing_with_stats = true

[honggfuzz]
iterations = 10000
timeout = 20
run_time = 20
exit_upon_crash = true

[afl]
iterations = 10000
timeout = 20
run_time = 20
4 changes: 2 additions & 2 deletions examples/hello_world/Trident.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ fuzzing_with_stats = true

[honggfuzz]
iterations = 1000
timeout = 20
run_time = 20
exit_upon_crash = false

[afl]
iterations = 10000
timeout = 20
run_time = 20
4 changes: 2 additions & 2 deletions examples/trident-benchmark/maze0/Trident.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ fuzzing_with_stats = true

[honggfuzz]
iterations = 10000
timeout = 20
run_time = 20
exit_upon_crash = true

[afl]
# iterations = 10000
# timeout = 20
# run_time = 20

0 comments on commit a9316e6

Please sign in to comment.