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)),
|
tuple_list!(MaxMapFeedback::new_with_observer(&edges_observer)),
|
||||||
// Corpus in which we store solutions (crashes in this example),
|
// Corpus in which we store solutions (crashes in this example),
|
||||||
// on disk so the user can get them after stopping the fuzzer
|
// 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
|
// Feedbacks to recognize an input as solution
|
||||||
tuple_list!(CrashFeedback::new()),
|
tuple_list!(CrashFeedback::new()),
|
||||||
)
|
)
|
||||||
|
@ -5,7 +5,7 @@ use core::cell::RefCell;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::path::PathBuf;
|
use std::{fs, path::PathBuf};
|
||||||
|
|
||||||
use crate::{corpus::Corpus, corpus::Testcase, inputs::Input, Error};
|
use crate::{corpus::Corpus, corpus::Testcase, inputs::Input, Error};
|
||||||
|
|
||||||
@ -94,11 +94,14 @@ impl<I> OnDiskCorpus<I>
|
|||||||
where
|
where
|
||||||
I: Input,
|
I: Input,
|
||||||
{
|
{
|
||||||
pub fn new(dir_path: PathBuf) -> Self {
|
/// Creates the OnDiskCorpus.
|
||||||
Self {
|
/// 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![],
|
entries: vec![],
|
||||||
current: None,
|
current: None,
|
||||||
dir_path: dir_path,
|
dir_path: dir_path,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user