fixed warnings, added testcase

This commit is contained in:
Dominik Maier 2020-10-28 22:45:21 +01:00
parent acc04e548e
commit 07bb8ae183
2 changed files with 16 additions and 7 deletions

View File

@ -147,7 +147,7 @@ impl<RandT: Rand> QueueCorpus<'_, RandT> {
}
#[derive(Debug, Default)]
struct SimpleTestcase {
pub struct SimpleTestcase {
is_on_disk: bool,
filename: String,
metadatas: HashMap<String, Box<dyn TestcaseMetadata>>,
@ -173,7 +173,7 @@ impl Testcase for SimpleTestcase {
}
impl SimpleTestcase {
fn new(filename: &str) -> Self {
pub fn new(filename: &str) -> Self {
SimpleTestcase {
filename: filename.to_owned(),
is_on_disk: false,

View File

@ -119,7 +119,6 @@ use unix_signals as os_signals;
compile_error!("InMemoryExecutor not yet supported on this OS");
impl Executor for InMemoryExecutor {
fn run_target(&mut self) -> Result<ExitKind, AflError> {
let bytes = match self.base.cur_input.as_ref() {
Some(i) => i.serialize(),
@ -165,7 +164,7 @@ impl Executor for InMemoryExecutor {
}
impl InMemoryExecutor {
fn new(harness_fn: HarnessFunction) -> InMemoryExecutor {
pub fn new(harness_fn: HarnessFunction) -> InMemoryExecutor {
InMemoryExecutor {
base: ExecutorBase {
observers: vec![],
@ -180,8 +179,18 @@ impl InMemoryExecutor {
mod tests {
use crate::executors::{Executor, ExitKind, InMemoryExecutor};
use crate::observers::Observer;
use crate::inputs::Input;
use crate::AflError;
struct NopInput {}
impl Input for NopInput{
fn serialize(&self) -> Result<&[u8], AflError> {Ok("NOP".as_bytes())}
fn deserialize(&mut self, _buf: &[u8]) -> Result<(), AflError> {
Ok(())
}
}
struct Nopserver {}
impl Observer for Nopserver {
@ -209,8 +218,8 @@ mod tests {
#[test]
fn test_inmem_exec() {
let mut in_mem_executor = InMemoryExecutor::new(test_harness_fn_nop);
let nopserver = Nopserver {};
in_mem_executor.add_observer(Box::new(nopserver));
assert_eq!(in_mem_executor.post_exec_observers().is_err(), true);
let input = NopInput{};
assert!(in_mem_executor.place_input(Box::new(input)).is_ok());
assert!(in_mem_executor.run_target().is_ok());
}
}