fixed warnings, added testcase
This commit is contained in:
parent
acc04e548e
commit
07bb8ae183
@ -147,7 +147,7 @@ impl<RandT: Rand> QueueCorpus<'_, RandT> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct SimpleTestcase {
|
pub struct SimpleTestcase {
|
||||||
is_on_disk: bool,
|
is_on_disk: bool,
|
||||||
filename: String,
|
filename: String,
|
||||||
metadatas: HashMap<String, Box<dyn TestcaseMetadata>>,
|
metadatas: HashMap<String, Box<dyn TestcaseMetadata>>,
|
||||||
@ -173,7 +173,7 @@ impl Testcase for SimpleTestcase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SimpleTestcase {
|
impl SimpleTestcase {
|
||||||
fn new(filename: &str) -> Self {
|
pub fn new(filename: &str) -> Self {
|
||||||
SimpleTestcase {
|
SimpleTestcase {
|
||||||
filename: filename.to_owned(),
|
filename: filename.to_owned(),
|
||||||
is_on_disk: false,
|
is_on_disk: false,
|
||||||
|
@ -119,7 +119,6 @@ use unix_signals as os_signals;
|
|||||||
compile_error!("InMemoryExecutor not yet supported on this OS");
|
compile_error!("InMemoryExecutor not yet supported on this OS");
|
||||||
|
|
||||||
impl Executor for InMemoryExecutor {
|
impl Executor for InMemoryExecutor {
|
||||||
|
|
||||||
fn run_target(&mut self) -> Result<ExitKind, AflError> {
|
fn run_target(&mut self) -> Result<ExitKind, AflError> {
|
||||||
let bytes = match self.base.cur_input.as_ref() {
|
let bytes = match self.base.cur_input.as_ref() {
|
||||||
Some(i) => i.serialize(),
|
Some(i) => i.serialize(),
|
||||||
@ -165,7 +164,7 @@ impl Executor for InMemoryExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl InMemoryExecutor {
|
impl InMemoryExecutor {
|
||||||
fn new(harness_fn: HarnessFunction) -> InMemoryExecutor {
|
pub fn new(harness_fn: HarnessFunction) -> InMemoryExecutor {
|
||||||
InMemoryExecutor {
|
InMemoryExecutor {
|
||||||
base: ExecutorBase {
|
base: ExecutorBase {
|
||||||
observers: vec![],
|
observers: vec![],
|
||||||
@ -180,8 +179,18 @@ impl InMemoryExecutor {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use crate::executors::{Executor, ExitKind, InMemoryExecutor};
|
use crate::executors::{Executor, ExitKind, InMemoryExecutor};
|
||||||
use crate::observers::Observer;
|
use crate::observers::Observer;
|
||||||
|
use crate::inputs::Input;
|
||||||
use crate::AflError;
|
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 {}
|
struct Nopserver {}
|
||||||
|
|
||||||
impl Observer for Nopserver {
|
impl Observer for Nopserver {
|
||||||
@ -209,8 +218,8 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_inmem_exec() {
|
fn test_inmem_exec() {
|
||||||
let mut in_mem_executor = InMemoryExecutor::new(test_harness_fn_nop);
|
let mut in_mem_executor = InMemoryExecutor::new(test_harness_fn_nop);
|
||||||
let nopserver = Nopserver {};
|
let input = NopInput{};
|
||||||
in_mem_executor.add_observer(Box::new(nopserver));
|
assert!(in_mem_executor.place_input(Box::new(input)).is_ok());
|
||||||
assert_eq!(in_mem_executor.post_exec_observers().is_err(), true);
|
assert!(in_mem_executor.run_target().is_ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user