fixed queuecorpus test

This commit is contained in:
Dominik Maier 2021-03-03 17:17:47 +01:00
parent eaa3dc786b
commit 447e5e0e59

View File

@ -70,48 +70,51 @@ where
} }
} }
/*
#[cfg(test)] #[cfg(test)]
#[cfg(feature = "std")] #[cfg(feature = "std")]
mod tests { mod tests {
use std::path::PathBuf; use std::{fs, path::PathBuf};
use crate::{ use crate::{
corpus::{Corpus, OnDiskCorpus, QueueCorpus, Testcase}, corpus::{Corpus, CorpusScheduler, OnDiskCorpus, QueueCorpusScheduler, Testcase},
inputs::bytes::BytesInput, inputs::bytes::BytesInput,
state::{HasCorpus, State},
utils::StdRand, utils::StdRand,
}; };
#[test] #[test]
fn test_queuecorpus() { fn test_queuecorpus() {
let mut rand = StdRand::new(0); let rand = StdRand::with_seed(4);
let mut q = QueueCorpus::new(OnDiskCorpus::<BytesInput, StdRand>::new(PathBuf::from( let scheduler = QueueCorpusScheduler::new();
"fancy/path",
))); let mut q =
let t = Testcase::with_filename(BytesInput::new(vec![0 as u8; 4]), "fancyfile".into()); OnDiskCorpus::<BytesInput>::new(PathBuf::from("target/.test/fancy/path")).unwrap();
q.add(t); let t = Testcase::with_filename(
let filename = q BytesInput::new(vec![0 as u8; 4]),
.next(&mut rand) "target/.test/fancy/path/fancyfile".into(),
);
q.add(t).unwrap();
let objective_q =
OnDiskCorpus::<BytesInput>::new(PathBuf::from("target/.test/fancy/objective/path"))
.unwrap();
let mut state = State::new(rand, q, (), objective_q, ());
let next_idx = scheduler.next(&mut state).unwrap();
let filename = state
.corpus()
.get(next_idx)
.unwrap() .unwrap()
.0
.borrow() .borrow()
.filename() .filename()
.as_ref() .as_ref()
.unwrap() .unwrap()
.to_owned(); .to_owned();
assert_eq!(
filename, assert_eq!(filename, "target/.test/fancy/path/fancyfile");
q.next(&mut rand)
.unwrap() fs::remove_dir_all("target/.test/fancy").unwrap();
.0
.borrow()
.filename()
.as_ref()
.unwrap()
.to_owned()
);
assert_eq!(filename, "fancyfile");
} }
} }
*/