Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» added more usefull parameters into toml
Browse files Browse the repository at this point in the history
  • Loading branch information
lukacan authored and lukacan committed Nov 13, 2023
1 parent c4ec51c commit 9a6ca6b
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 11 deletions.
47 changes: 42 additions & 5 deletions crates/client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ struct _Fuzz {
/// --extension
/// -e
pub extension: Option<String>,
#[serde(default)]
/// Number of seconds this fuzzing session will last (default: 0 [no limit])
/// --run_time
pub run_time: Option<u32>,
#[serde(default)]
/// Maximal size of files processed by the fuzzer in bytes (default: 1048576 = 1MB)
/// --max_file_size
/// -F
pub max_file_size: Option<u32>,
#[serde(default)]
/// Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames (default: false)
/// --save_all
/// -u
pub save_all: Option<bool>,
}
impl Default for Fuzz {
fn default() -> Self {
Expand All @@ -102,6 +116,8 @@ impl Default for Fuzz {
FuzzArg::new("-N", "--iterations", &0.to_string()),
FuzzArg::new("-r", "--mutations_per_run", &6.to_string()),
FuzzArg::new("-e", "--extension", "fuzz"),
FuzzArg::new("", "--run_time", &0.to_string()),
FuzzArg::new("-F", "--max_file_size", &1_048_576.to_string()),
],
}
}
Expand Down Expand Up @@ -164,6 +180,24 @@ impl From<_Fuzz> for Fuzz {
.fuzz_args
.push(FuzzArg::new("-e", "--extension", &extension));
}
// run_time
let run_time = _f.run_time.unwrap_or(0);
_self
.fuzz_args
.push(FuzzArg::new("", "--run_time", &run_time.to_string()));

// max_file_size
let max_file_size = _f.max_file_size.unwrap_or(1_048_576);
_self.fuzz_args.push(FuzzArg::new(
"-F",
"--max_file_size",
&max_file_size.to_string(),
));
// save_all
let save_all = _f.save_all.unwrap_or(false);
if save_all {
_self.fuzz_args.push(FuzzArg::new("-u", "--save_all", ""));
}
_self
}
}
Expand Down Expand Up @@ -287,7 +321,10 @@ mod tests {
};

let env_var_string = config.get_fuzz_args(String::default());
assert_eq!(env_var_string, "-t 10 -N 0 -r 6 -e fuzz ");
assert_eq!(
env_var_string,
"-t 10 -N 0 -r 6 -e fuzz --run_time 0 -F 1048576 "
);
}
#[test]
fn test_merge_and_precedence2() {
Expand All @@ -300,7 +337,7 @@ mod tests {

assert_eq!(
env_var_string,
"-t 10 -N 0 -r 6 -e fuzz -t 0 -N10 --exit_upon_crash"
"-t 10 -N 0 -r 6 -e fuzz --run_time 0 -F 1048576 -t 0 -N10 --exit_upon_crash"
);
}
#[test]
Expand All @@ -313,7 +350,7 @@ mod tests {
config.get_fuzz_args("-t 100 -N 5000 -Q -v --exit_upon_crash".to_string());
assert_eq!(
env_var_string,
"-t 10 -N 0 -r 6 -e fuzz -t 100 -N 5000 -Q -v --exit_upon_crash"
"-t 10 -N 0 -r 6 -e fuzz --run_time 0 -F 1048576 -t 100 -N 5000 -Q -v --exit_upon_crash"
);
}
#[test]
Expand All @@ -326,7 +363,7 @@ mod tests {
let env_var_string = config.get_fuzz_args("-t 10 -N 500 -Q -v --exit_upon_crash -n 15 --mutations_per_run 8 --verifier -W random_dir --crashdir random_dir5 --run_time 666".to_string());
assert_eq!(
env_var_string,
"-t 10 -N 0 -r 6 -e fuzz -t 10 -N 500 -Q -v --exit_upon_crash -n 15 --mutations_per_run 8 --verifier -W random_dir --crashdir random_dir5 --run_time 666"
"-t 10 -N 0 -r 6 -e fuzz --run_time 0 -F 1048576 -t 10 -N 500 -Q -v --exit_upon_crash -n 15 --mutations_per_run 8 --verifier -W random_dir --crashdir random_dir5 --run_time 666"
);
}
#[test]
Expand All @@ -339,7 +376,7 @@ mod tests {
let env_var_string = config.get_fuzz_args("-t 10 -N 500 -Q -v --exit_upon_crash -n 15 --verifier -W random_dir --crashdir random_dir5 --run_time 666".to_string());
assert_eq!(
env_var_string,
"-t 10 -N 0 -r 6 -e fuzz -t 10 -N 500 -Q -v --exit_upon_crash -n 15 --verifier -W random_dir --crashdir random_dir5 --run_time 666"
"-t 10 -N 0 -r 6 -e fuzz --run_time 0 -F 1048576 -t 10 -N 500 -Q -v --exit_upon_crash -n 15 --verifier -W random_dir --crashdir random_dir5 --run_time 666"
);
}
}
8 changes: 7 additions & 1 deletion crates/client/src/templates/Trdelnik.toml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ iterations = 0
keep_output = false
# Disable ANSI console; use simple log output (default: false)
verbose = false
Exit upon seeing the first crash (default: false)
# Exit upon seeing the first crash (default: false)
exit_upon_crash = false
# Maximal number of mutations per one run (default: 6)
mutations_per_run = 6
# Directory where crashes are saved to (default: workspace directory)
crashdir = ""
# Input file extension (e.g. 'swf'), (default: 'fuzz')
extension = ""
# Number of seconds this fuzzing session will last (default: 0 [no limit])
run_time = 0
# Maximal size of files processed by the fuzzer in bytes (default: 1048576 = 1MB)
max_file_size = 1048576
# Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames (default: false)
save_all = false
26 changes: 21 additions & 5 deletions examples/fuzzer/Trdelnik.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
[test]
validator_startup_timeout = 15000


# contains default values
[fuzz]
# Timeout in seconds (default: 10)
timeout = 10
# Number of fuzzing iterations (default: 0 [no limit])
iterations = 1000
timeout = 25
# Don't close children's stdin, stdout, stderr; can be noisy (default: false)
keep_output = false
# Disable ANSI console; use simple log output (default: false)
verbose = false
exit_upon_crash = true
mutations_per_run = 20
# (default: workspace directory)
crashdir = "./try1"
# Exit upon seeing the first crash (default: false)
exit_upon_crash = false
# Maximal number of mutations per one run (default: 6)
mutations_per_run = 6
# Directory where crashes are saved to (default: workspace directory)
crashdir = ""
# Input file extension (e.g. 'swf'), (default: 'fuzz')
extension = ""
# Number of seconds this fuzzing session will last (default: 0 [no limit])
run_time = 0
# Maximal size of files processed by the fuzzer in bytes (default: 1048576 = 1MB)
max_file_size = 1048576
# Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames (default: false)
save_all = true

0 comments on commit 9a6ca6b

Please sign in to comment.