Making input_tester and expand immutable (#500)

This commit is contained in:
Cheick Keita
2021-02-04 12:18:15 -08:00
committed by GitHub
parent 220fe46f9d
commit a50eb94db5
10 changed files with 145 additions and 149 deletions

View File

@ -48,10 +48,10 @@ fn main() -> Result<()> {
async fn run(args: ArgMatches<'_>) -> Result<()> {
match args.subcommand() {
(LICENSE_CMD, Some(_)) => return licenses(),
(DEBUG_CMD, Some(sub)) => return debug::cmd::run(sub).await,
(LOCAL_CMD, Some(sub)) => return local::cmd::run(sub).await,
(MANAGED_CMD, Some(sub)) => return managed::cmd::run(sub).await,
(LICENSE_CMD, Some(_)) => licenses(),
(DEBUG_CMD, Some(sub)) => debug::cmd::run(sub).await,
(LOCAL_CMD, Some(sub)) => local::cmd::run(sub).await,
(MANAGED_CMD, Some(sub)) => managed::cmd::run(sub).await,
_ => {
anyhow::bail!("missing subcommand\nUSAGE: {}", args.usage());
}

View File

@ -114,9 +114,7 @@ async fn poll_inputs(config: &Config, tmp_dir: OwnedDir) -> Result<()> {
}
pub async fn run_tool(input: impl AsRef<Path>, config: &Config) -> Result<()> {
let mut expand = Expand::new();
expand
let expand = Expand::new()
.input_path(&input)
.target_exe(&config.target_exe)
.target_options(&config.target_options)

View File

@ -91,20 +91,18 @@ impl GeneratorTask {
}
async fn fuzzing_loop(&self, heartbeat_client: Option<TaskHeartbeatClient>) -> Result<()> {
let mut tester = Tester::new(
let tester = Tester::new(
&self.config.common.setup_dir,
&self.config.target_exe,
&self.config.target_options,
&self.config.target_env,
);
tester
.check_asan_log(self.config.check_asan_log)
.check_debugger(self.config.check_debugger)
.check_retry_count(self.config.check_retry_count);
if let Some(timeout) = self.config.target_timeout {
tester.timeout(timeout);
}
)
.check_asan_log(self.config.check_asan_log)
.check_debugger(self.config.check_debugger)
.check_retry_count(self.config.check_retry_count)
.set_optional(self.config.target_timeout, |tester, timeout| {
tester.timeout(timeout)
});
loop {
for corpus_dir in &self.config.readonly_inputs {
@ -154,18 +152,16 @@ impl GeneratorTask {
) -> Result<()> {
utils::reset_tmp_dir(&output_dir).await?;
let (mut generator, generator_path) = {
let mut expand = Expand::new();
expand
let expand = Expand::new()
.generated_inputs(&output_dir)
.input_corpus(&corpus_dir)
.generator_exe(&self.config.generator_exe)
.generator_options(&self.config.generator_options)
.job_id(&self.config.common.job_id)
.task_id(&self.config.common.task_id);
if let Some(tools) = &self.config.tools {
expand.tools_dir(&tools.path);
}
.task_id(&self.config.common.task_id)
.set_optional_ref(&self.config.tools, |expand, tools| {
expand.tools_dir(&tools.path)
});
let generator_path = expand.evaluate_value(&self.config.generator_exe)?;

View File

@ -173,8 +173,7 @@ async fn start_supervisor(
inputs: &SyncedDir,
reports_dir: PathBuf,
) -> Result<Child> {
let mut expand = Expand::new();
expand
let expand = Expand::new()
.supervisor_exe(&config.supervisor_exe)
.supervisor_options(&config.supervisor_options)
.runtime_dir(&runtime_dir)
@ -183,23 +182,17 @@ async fn start_supervisor(
.reports_dir(&reports_dir)
.setup_dir(&config.common.setup_dir)
.job_id(&config.common.job_id)
.task_id(&config.common.task_id);
if let Some(tools) = &config.tools {
expand.tools_dir(&tools.path);
}
if let Some(target_exe) = &config.target_exe {
expand.target_exe(target_exe);
}
if let Some(target_options) = &config.target_options {
expand.target_options(target_options);
}
if let Some(input_marker) = &config.supervisor_input_marker {
expand.input_marker(input_marker);
}
.task_id(&config.common.task_id)
.set_optional_ref(&config.tools, |expand, tools| expand.tools_dir(&tools.path))
.set_optional_ref(&config.target_exe, |expand, target_exe| {
expand.target_exe(target_exe)
})
.set_optional_ref(&config.supervisor_input_marker, |expand, input_marker| {
expand.input_marker(input_marker)
})
.set_optional_ref(&config.target_options, |expand, target_options| {
expand.target_options(target_options)
});
let supervisor_path = expand.evaluate_value(&config.supervisor_exe)?;
let mut cmd = Command::new(supervisor_path);

View File

@ -129,9 +129,7 @@ async fn try_delete_blob(input_url: Url) -> Result<()> {
}
async fn merge(config: &Config, output_dir: impl AsRef<Path>) -> Result<()> {
let mut expand = Expand::new();
expand
let expand = Expand::new()
.input_marker(&config.supervisor_input_marker)
.input_corpus(&config.unique_inputs.path)
.target_options(&config.target_options)

View File

@ -118,17 +118,15 @@ pub struct GenericReportProcessor<'a> {
impl<'a> GenericReportProcessor<'a> {
pub fn new(config: &'a Config, heartbeat_client: Option<TaskHeartbeatClient>) -> Self {
let mut tester = Tester::new(
let tester = Tester::new(
&config.common.setup_dir,
&config.target_exe,
&config.target_options,
&config.target_env,
);
tester
.check_asan_log(config.check_asan_log)
.check_debugger(config.check_debugger)
.check_retry_count(config.check_retry_count);
)
.check_asan_log(config.check_asan_log)
.check_debugger(config.check_debugger)
.check_retry_count(config.check_retry_count);
Self {
config,