Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» threads param
Browse files Browse the repository at this point in the history
  • Loading branch information
lukacan authored and lukacan committed Feb 7, 2024
1 parent 00eecbd commit 1136bba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
13 changes: 0 additions & 13 deletions crates/client/src/commander.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ pub const PROGRAM_CLIENT_DIRECTORY: &str = ".program_client";
pub const CARGO_TARGET_DIR_DEFAULT: &str = "trdelnik-tests/fuzz_tests/fuzzing/hfuzz_target";
pub const HFUZZ_WORKSPACE_DEFAULT: &str = "trdelnik-tests/fuzz_tests/fuzzing/hfuzz_workspace";

pub const TESTS_WORKSPACE: &str = "trdelnik-tests";
pub const HFUZZ_WORKSPACE: &str = "hfuzz_workspace";

#[derive(Error, Debug)]
pub enum Error {
#[error("{0:?}")]
Expand Down Expand Up @@ -256,16 +253,6 @@ impl Commander {
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
},
}

if let Ok(crash_files) = get_crash_files(&crash_dir, &ext) {
if !crash_files.is_empty() {
println!(
"The crash directory {} contains new fuzz test crashes. Exiting!",
crash_dir.to_string_lossy()
);
std::process::exit(1);
}
}
}

/// Runs fuzzer on the given target.
Expand Down
21 changes: 17 additions & 4 deletions crates/client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ struct _Fuzz {
/// --iterations
pub iterations: Option<u64>,
#[serde(default)]
/// Number of concurrent fuzzing threads (default: number of CPUs / 2)
/// -n
/// --threads
pub threads: Option<u16>,
#[serde(default)]
/// Don't close children's stdin, stdout, stderr; can be noisy
/// -Q
/// --keep_output
Expand All @@ -81,31 +86,31 @@ struct _Fuzz {
pub exit_upon_crash: Option<bool>,
#[serde(default)]
/// Maximal number of mutations per one run (default: 6)
/// --mutations_per_run
/// -r
/// --mutations_per_run
pub mutations_per_run: Option<u16>,
#[serde(default)]
/// Directory where crashes are saved to (default: workspace directory)
/// --crashdir
pub crashdir: Option<String>,
#[serde(default)]
/// Input file extension (e.g. 'swf'), (default: 'fuzz')
/// --extension
/// -e
/// --extension
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
/// --max_file_size
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
/// --save_all
pub save_all: Option<bool>,
}
impl Default for Fuzz {
Expand Down Expand Up @@ -138,6 +143,14 @@ impl From<_Fuzz> for Fuzz {
.fuzz_args
.push(FuzzArg::new("-N", "--iterations", &iterations.to_string()));

// threads
let threads = _f.threads.unwrap_or(0);
if threads > 0 {
_self
.fuzz_args
.push(FuzzArg::new("-n", "--threads", &threads.to_string()));
}

// keep_output
let keep_output = _f.keep_output.unwrap_or(false);
if keep_output {
Expand Down
6 changes: 4 additions & 2 deletions crates/client/src/templates/Trdelnik.toml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ validator_startup_timeout = 15000
timeout = 10
# Number of fuzzing iterations (default: 0 [no limit])
iterations = 0
# Number of concurrent fuzzing threads (default: 0 [number of CPUs / 2])
threads = 0
# 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)
Expand All @@ -16,9 +18,9 @@ verbose = 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)
# Directory where crashes are saved to (default: "" [workspace directory])
crashdir = ""
# Input file extension (e.g. 'swf'), (default: 'fuzz')
# Input file extension (e.g. 'swf'), (default: "" ['fuzz'])
extension = ""
# Number of seconds this fuzzing session will last (default: 0 [no limit])
run_time = 0
Expand Down

0 comments on commit 1136bba

Please sign in to comment.