From e40b26ffbc834e8d9e119885a04887706003b9b8 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Wed, 3 Feb 2021 20:29:05 +0100 Subject: [PATCH] tests fixed --- afl/src/engines/mod.rs | 8 ++++---- afl/src/executors/inmemory.rs | 24 +++++++----------------- afl/src/executors/mod.rs | 2 ++ 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/afl/src/engines/mod.rs b/afl/src/engines/mod.rs index 9fca52c995..9b90963741 100644 --- a/afl/src/engines/mod.rs +++ b/afl/src/engines/mod.rs @@ -516,9 +516,9 @@ mod tests { corpus::{Corpus, InMemoryCorpus, Testcase}, engines::{Engine, Fuzzer, State, StdFuzzer}, executors::{Executor, ExitKind, InMemoryExecutor}, - inputs::bytes::BytesInput, + inputs::{Input, BytesInput}, mutators::{mutation_bitflip, ComposedByMutations, StdScheduledMutator}, - stages::mutational::StdMutationalStage, + stages::StdMutationalStage, tuples::tuple_list, utils::StdRand, }; @@ -526,7 +526,7 @@ mod tests { #[cfg(feature = "std")] use crate::events::{LoggerEventManager, SimpleStats}; - fn harness(_executor: &dyn Executor, _buf: &[u8]) -> ExitKind { + fn harness, I: Input>(_executor: &E, _buf: &[u8]) -> ExitKind { ExitKind::Ok } @@ -548,7 +548,7 @@ mod tests { "main", harness, tuple_list!(), - Box::new(|_, _, _, _, _| ()), + //Box::new(|_, _, _, _, _| ()), &state, &corpus, &mut event_manager, diff --git a/afl/src/executors/inmemory.rs b/afl/src/executors/inmemory.rs index efcd3276af..cf72df251b 100644 --- a/afl/src/executors/inmemory.rs +++ b/afl/src/executors/inmemory.rs @@ -374,43 +374,33 @@ pub mod unix_signals { #[cfg(test)] mod tests { - use alloc::boxed::Box; + use core::marker::PhantomData; use crate::{ - executors::{Executor, ExitKind, InMemoryExecutor}, - inputs::NopInput, + executors::{Executor, InMemoryExecutor, ExitKind}, + inputs::Input, tuples::tuple_list, }; - #[cfg(feature = "std")] - fn test_harness_fn_nop(_executor: &dyn Executor, 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, _buf: &[u8]) -> ExitKind { + fn test_harness_fn_nop, I: Input>(_executor: &E, _buf: &[u8]) -> ExitKind { ExitKind::Ok } #[test] fn test_inmem_exec() { use crate::{ - corpus::InMemoryCorpus, events::NopEventManager, inputs::NopInput, utils::StdRand, + inputs::NopInput, }; let mut in_mem_executor = InMemoryExecutor::< NopInput, (), - InMemoryCorpus<_, _>, - NopEventManager<_>, - (), - StdRand, > { harness_fn: test_harness_fn_nop, - on_crash_fn: Box::new(|_, _, _, _, _| ()), + // TODO: on_crash_fn: Box::new(|_, _, _, _, _| ()), observers: tuple_list!(), name: "main", + phantom: PhantomData, }; let mut input = NopInput {}; assert!(in_mem_executor.run_target(&mut input).is_ok()); diff --git a/afl/src/executors/mod.rs b/afl/src/executors/mod.rs index ca7ff4970b..cea7d92114 100644 --- a/afl/src/executors/mod.rs +++ b/afl/src/executors/mod.rs @@ -1,3 +1,5 @@ +//! Executors take input, and run it in the target. + pub mod inmemory; pub use inmemory::InMemoryExecutor; #[cfg(feature = "runtime")]