tests fixed

This commit is contained in:
Dominik Maier 2021-02-03 20:29:05 +01:00
parent ab793303fb
commit e40b26ffbc
3 changed files with 13 additions and 21 deletions

View File

@ -516,9 +516,9 @@ mod tests {
corpus::{Corpus, InMemoryCorpus, Testcase}, corpus::{Corpus, InMemoryCorpus, Testcase},
engines::{Engine, Fuzzer, State, StdFuzzer}, engines::{Engine, Fuzzer, State, StdFuzzer},
executors::{Executor, ExitKind, InMemoryExecutor}, executors::{Executor, ExitKind, InMemoryExecutor},
inputs::bytes::BytesInput, inputs::{Input, BytesInput},
mutators::{mutation_bitflip, ComposedByMutations, StdScheduledMutator}, mutators::{mutation_bitflip, ComposedByMutations, StdScheduledMutator},
stages::mutational::StdMutationalStage, stages::StdMutationalStage,
tuples::tuple_list, tuples::tuple_list,
utils::StdRand, utils::StdRand,
}; };
@ -526,7 +526,7 @@ mod tests {
#[cfg(feature = "std")] #[cfg(feature = "std")]
use crate::events::{LoggerEventManager, SimpleStats}; use crate::events::{LoggerEventManager, SimpleStats};
fn harness<I>(_executor: &dyn Executor<I>, _buf: &[u8]) -> ExitKind { fn harness<E: Executor<I>, I: Input>(_executor: &E, _buf: &[u8]) -> ExitKind {
ExitKind::Ok ExitKind::Ok
} }
@ -548,7 +548,7 @@ mod tests {
"main", "main",
harness, harness,
tuple_list!(), tuple_list!(),
Box::new(|_, _, _, _, _| ()), //Box::new(|_, _, _, _, _| ()),
&state, &state,
&corpus, &corpus,
&mut event_manager, &mut event_manager,

View File

@ -374,43 +374,33 @@ pub mod unix_signals {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use alloc::boxed::Box; use core::marker::PhantomData;
use crate::{ use crate::{
executors::{Executor, ExitKind, InMemoryExecutor}, executors::{Executor, InMemoryExecutor, ExitKind},
inputs::NopInput, inputs::Input,
tuples::tuple_list, tuples::tuple_list,
}; };
#[cfg(feature = "std")] fn test_harness_fn_nop<E: Executor<I>, I: Input>(_executor: &E, _buf: &[u8]) -> ExitKind {
fn test_harness_fn_nop(_executor: &dyn Executor<NopInput>, buf: &[u8]) -> ExitKind {
println!("Fake exec with buf of len {}", buf.len());
ExitKind::Ok
}
#[cfg(not(feature = "std"))]
fn test_harness_fn_nop(_executor: &dyn Executor<NopInput>, _buf: &[u8]) -> ExitKind {
ExitKind::Ok ExitKind::Ok
} }
#[test] #[test]
fn test_inmem_exec() { fn test_inmem_exec() {
use crate::{ use crate::{
corpus::InMemoryCorpus, events::NopEventManager, inputs::NopInput, utils::StdRand, inputs::NopInput,
}; };
let mut in_mem_executor = InMemoryExecutor::< let mut in_mem_executor = InMemoryExecutor::<
NopInput, NopInput,
(), (),
InMemoryCorpus<_, _>,
NopEventManager<_>,
(),
StdRand,
> { > {
harness_fn: test_harness_fn_nop, harness_fn: test_harness_fn_nop,
on_crash_fn: Box::new(|_, _, _, _, _| ()), // TODO: on_crash_fn: Box::new(|_, _, _, _, _| ()),
observers: tuple_list!(), observers: tuple_list!(),
name: "main", name: "main",
phantom: PhantomData,
}; };
let mut input = NopInput {}; let mut input = NopInput {};
assert!(in_mem_executor.run_target(&mut input).is_ok()); assert!(in_mem_executor.run_target(&mut input).is_ok());

View File

@ -1,3 +1,5 @@
//! Executors take input, and run it in the target.
pub mod inmemory; pub mod inmemory;
pub use inmemory::InMemoryExecutor; pub use inmemory::InMemoryExecutor;
#[cfg(feature = "runtime")] #[cfg(feature = "runtime")]