MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / archive

Function archive

src/bin/harness.rs:228–284  ·  view source on GitHub ↗
(project: String, suffix: &Option<String>)

Source from the content-addressed store, hash-verified

226}
227
228fn archive(project: String, suffix: &Option<String>) -> Result<()> {
229 let current_date = Local::now().format("%Y-%m-%d").to_string();
230
231 let out: String = if let Some(suffix) = suffix {
232 format!("{project}_{suffix}_{current_date}.tar.gz")
233 } else {
234 format!("{project}_{current_date}.tar.gz")
235 };
236
237 let deopt = Deopt::new(project.clone())?;
238 let driver_dir = deopt.get_library_driver_dir()?;
239 if driver_dir.exists() {
240 std::fs::remove_dir_all(driver_dir)?;
241 }
242
243 let fuzzer_dir: PathBuf = deopt.get_library_fuzzer_dir(false)?;
244 let exploit_fuzzer_dir: PathBuf = deopt.get_library_fuzzer_dir(true)?;
245 let fuzzer_dirs = vec![fuzzer_dir, exploit_fuzzer_dir];
246 for fuzz_dir in fuzzer_dirs {
247 for entry in crate::deopt::utils::read_sort_dir(&fuzz_dir)? {
248 if entry.is_dir() {
249 let corpus_path: PathBuf = [entry.clone(), "corpus".into()].iter().collect();
250 if corpus_path.exists() {
251 std::fs::remove_dir_all(corpus_path)?;
252 }
253 let profraw: PathBuf = [entry.clone(), "profraw".into()].iter().collect();
254 if profraw.exists() {
255 std::fs::remove_dir_all(profraw)?;
256 }
257 }
258 }
259 }
260
261 let _cmd = Command::new("tar")
262 .current_dir(Deopt::get_crate_output_dir()?)
263 .arg("-cvf")
264 .arg(&out)
265 .arg("-C")
266 .arg(Deopt::get_crate_output_dir()?)
267 .arg(format!("--exclude={project}/work"))
268 .arg(&project)
269 .stdout(Stdio::inherit())
270 .stderr(Stdio::inherit())
271 .output()?;
272
273 let _cmd = Command::new("coscli")
274 .current_dir(Deopt::get_crate_output_dir()?)
275 .arg("cp")
276 .arg(out.clone())
277 .arg(format!(
278 "cos://sbd-testing-1251316161/bench_archive/LLM_FUZZ/{project}/{out}"
279 ))
280 .stderr(Stdio::inherit())
281 .stdout(Stdio::inherit())
282 .output()?;
283 Ok(())
284}
285

Callers 1

mainFunction · 0.85

Calls 3

read_sort_dirFunction · 0.85

Tested by

no test coverage detected