Skip to content

Commit

Permalink
Expand tools_dir accessibility in variable expansion (microsoft#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmc-msft authored and chkeita committed Jan 29, 2021
1 parent 7674186 commit db94935
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
13 changes: 6 additions & 7 deletions src/agent/onefuzz-agent/src/tasks/analysis/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,30 +114,29 @@ async fn poll_inputs(config: &Config, tmp_dir: OwnedDir) -> Result<()> {
}

pub async fn run_tool(input: impl AsRef<Path>, config: &Config) -> Result<()> {
let mut tool_args = Expand::new();
let mut expand = Expand::new();

tool_args
expand
.input_path(&input)
.target_exe(&config.target_exe)
.target_options(&config.target_options)
.analyzer_exe(&config.analyzer_exe)
.analyzer_options(&config.analyzer_options)
.output_dir(&config.analysis.path)
.tools_dir(&config.tools.path)
.setup_dir(&config.common.setup_dir);

let analyzer_path = Expand::new()
.tools_dir(&config.tools.path)
.evaluate_value(&config.analyzer_exe)?;
let analyzer_path = expand.evaluate_value(&config.analyzer_exe)?;

let mut cmd = Command::new(analyzer_path);
cmd.kill_on_drop(true).env_remove("RUST_LOG");

for arg in tool_args.evaluate(&config.analyzer_options)? {
for arg in expand.evaluate(&config.analyzer_options)? {
cmd.arg(arg);
}

for (k, v) in &config.analyzer_env {
cmd.env(k, tool_args.evaluate_value(v)?);
cmd.env(k, expand.evaluate_value(v)?);
}

cmd.output().await?;
Expand Down
21 changes: 8 additions & 13 deletions src/agent/onefuzz-agent/src/tasks/merge/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,20 @@ async fn try_delete_blob(input_url: Url) -> Result<()> {
}

async fn merge(config: &Config, output_dir: impl AsRef<Path>) -> Result<()> {
let mut supervisor_args = Expand::new();
let mut expand = Expand::new();

supervisor_args
expand
.input_marker(&config.supervisor_input_marker)
.input_corpus(&config.unique_inputs.path)
.target_options(&config.target_options)
.supervisor_exe(&config.supervisor_exe)
.supervisor_options(&config.supervisor_options)
.generated_inputs(output_dir)
.target_exe(&config.target_exe)
.setup_dir(&config.common.setup_dir);
.setup_dir(&config.common.setup_dir)
.tools_dir(&config.tools.path);

if config.target_options_merge {
supervisor_args.target_options(&config.target_options);
}

let supervisor_path = Expand::new()
.tools_dir(&config.tools.path)
.evaluate_value(&config.supervisor_exe)?;
let supervisor_path = expand.evaluate_value(&config.supervisor_exe)?;

let mut cmd = Command::new(supervisor_path);

Expand All @@ -157,15 +152,15 @@ async fn merge(config: &Config, output_dir: impl AsRef<Path>) -> Result<()> {
.stderr(Stdio::piped());

for (k, v) in &config.supervisor_env {
cmd.env(k, v);
cmd.env(k, expand.evaluate_value(v)?);
}

for arg in supervisor_args.evaluate(&config.supervisor_options)? {
for arg in expand.evaluate(&config.supervisor_options)? {
cmd.arg(arg);
}

if !config.target_options_merge {
for arg in supervisor_args.evaluate(&config.target_options)? {
for arg in expand.evaluate(&config.target_options)? {
cmd.arg(arg);
}
}
Expand Down

0 comments on commit db94935

Please sign in to comment.