Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Create directories if they don't exist in the template #3522

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/agent/onefuzz-task/src/local/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,16 @@ impl RunContext {
name: impl AsRef<str>,
path: impl AsRef<Path>,
) -> Result<SyncedDir> {
if !path.as_ref().exists() {
std::fs::create_dir_all(&path)?;
}

self.to_sync_dir(name, path)?
.monitor_count(&self.event_sender)
}

pub fn to_sync_dir(&self, name: impl AsRef<str>, path: impl AsRef<Path>) -> Result<SyncedDir> {
let path = path.as_ref();
if !path.exists() {
std::fs::create_dir_all(path)?;
}

let name = name.as_ref();
let current_dir = std::env::current_dir()?;
if self.create_job_dir {
Expand Down
16 changes: 6 additions & 10 deletions src/agent/onefuzz-task/tests/template_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::{
path::{Path, PathBuf},
};

use path_absolutize::Absolutize;
use tokio::fs;

use anyhow::Result;
Expand Down Expand Up @@ -131,25 +132,20 @@ async fn create_test_directory(config: &Path, target_exe: &Path) -> Result<TestL
test_directory = test_directory.canonicalize()?;

let mut inputs_directory = PathBuf::from(&test_directory).join("inputs");
fs::create_dir(&inputs_directory).await?;
inputs_directory = inputs_directory.canonicalize()?;
inputs_directory = inputs_directory.absolutize()?.into();

let mut crashes_directory = PathBuf::from(&test_directory).join("crashes");
fs::create_dir(&crashes_directory).await?;
crashes_directory = crashes_directory.canonicalize()?;
crashes_directory = crashes_directory.absolutize()?.into();

let mut crashdumps_directory = PathBuf::from(&test_directory).join("crashdumps");
fs::create_dir(&crashdumps_directory).await?;
crashdumps_directory = crashdumps_directory.canonicalize()?;
crashdumps_directory = crashdumps_directory.absolutize()?.into();

let mut coverage_directory = PathBuf::from(&test_directory).join("coverage");
fs::create_dir(&coverage_directory).await?;
coverage_directory = coverage_directory.canonicalize()?;
coverage_directory = coverage_directory.absolutize()?.into();

let mut regression_reports_directory =
PathBuf::from(&test_directory).join("regression_reports");
fs::create_dir(&regression_reports_directory).await?;
regression_reports_directory = regression_reports_directory.canonicalize()?;
regression_reports_directory = regression_reports_directory.absolutize()?.into();

let mut target_in_test = PathBuf::from(&test_directory).join("fuzz.exe");
fs::copy(target_exe, &target_in_test).await?;
Expand Down
Loading