OnDiskCorpus autocreates dictionaries
This commit is contained in:
parent
bb29e6dd72
commit
061a8dd77c
@ -92,7 +92,7 @@ fn fuzz(corpus_dirs: Vec<PathBuf>, objective_dir: PathBuf, broker_port: u16) ->
|
||||
tuple_list!(MaxMapFeedback::new_with_observer(&edges_observer)),
|
||||
// Corpus in which we store solutions (crashes in this example),
|
||||
// on disk so the user can get them after stopping the fuzzer
|
||||
OnDiskCorpus::new(objective_dir),
|
||||
OnDiskCorpus::new(objective_dir).unwrap(),
|
||||
// Feedbacks to recognize an input as solution
|
||||
tuple_list!(CrashFeedback::new()),
|
||||
)
|
||||
|
@ -5,7 +5,7 @@ use core::cell::RefCell;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std::path::PathBuf;
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
use crate::{corpus::Corpus, corpus::Testcase, inputs::Input, Error};
|
||||
|
||||
@ -94,11 +94,14 @@ impl<I> OnDiskCorpus<I>
|
||||
where
|
||||
I: Input,
|
||||
{
|
||||
pub fn new(dir_path: PathBuf) -> Self {
|
||||
Self {
|
||||
/// Creates the OnDiskCorpus.
|
||||
/// Will error, if `std::fs::create_dir_all` failed for `dir_path`.
|
||||
pub fn new(dir_path: PathBuf) -> Result<Self, Error> {
|
||||
fs::create_dir_all(&dir_path)?;
|
||||
Ok(Self {
|
||||
entries: vec![],
|
||||
current: None,
|
||||
dir_path: dir_path,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user