fuzzes again

This commit is contained in:
Dominik Maier 2020-12-13 23:56:44 +01:00
parent afce4f3330
commit 52e1f52e1d
3 changed files with 14 additions and 10 deletions

View File

@ -55,7 +55,7 @@ where
} }
/// Events sent around in the library /// Events sent around in the library
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(bound = "I: serde::de::DeserializeOwned")] #[serde(bound = "I: serde::de::DeserializeOwned")]
pub enum Event<I> pub enum Event<I>
where where
@ -232,6 +232,13 @@ where
/// Broker fun /// Broker fun
fn handle_in_broker(&mut self, event: &Event<I>) -> Result<BrokerEventResult, AflError> { fn handle_in_broker(&mut self, event: &Event<I>) -> Result<BrokerEventResult, AflError> {
match event { match event {
Event::LoadInitial {
sender_id: _,
phantom: _,
} => {
self.corpus_size_inc();
Ok(BrokerEventResult::Handled)
},
Event::NewTestcase { Event::NewTestcase {
sender_id: _, sender_id: _,
input: _, input: _,
@ -249,7 +256,7 @@ where
} }
Event::UpdateStats { Event::UpdateStats {
sender_id, sender_id,
executions: _, executions,
execs_over_sec: _, execs_over_sec: _,
phantom: _, phantom: _,
} => { } => {
@ -263,7 +270,8 @@ where
executions: 0, executions: 0,
}) })
} }
let stat = &mut self.client_stats_mut()[*sender_id as usize]; let mut stat = &mut self.client_stats_mut()[*sender_id as usize];
stat.executions = *executions as u64;
println!( println!(
"[UPDATE] corpus: {} execs: {} execs/s: {}", "[UPDATE] corpus: {} execs: {} execs/s: {}",
self.corpus_size(), self.corpus_size(),
@ -323,7 +331,7 @@ where
Ok(()) Ok(())
} }
_ => Err(AflError::Unknown( _ => Err(AflError::Unknown(
"Received illegal message that message should not have arrived.".into(), format!("Received illegal message that message should not have arrived: {:?}.", event),
)), )),
} }
} }
@ -462,11 +470,8 @@ where
//CE: CustomEvent<I>, //CE: CustomEvent<I>,
{ {
writer: W, writer: W,
count: usize,
// stats (maybe we need a separated struct?) // stats (maybe we need a separated struct?)
executions: usize,
execs_over_sec: u64,
corpus_size: usize, corpus_size: usize,
start_time: time::Duration, start_time: time::Duration,
client_stats: Vec<ClientStats>, client_stats: Vec<ClientStats>,

View File

@ -3,6 +3,7 @@ pub use bytes::BytesInput;
use alloc::vec::Vec; use alloc::vec::Vec;
use core::clone::Clone; use core::clone::Clone;
use core::fmt::Debug;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::fs::File; use std::fs::File;
@ -14,7 +15,7 @@ use std::path::Path;
use crate::AflError; use crate::AflError;
/// An input for the target /// An input for the target
pub trait Input: Clone + serde::Serialize + serde::de::DeserializeOwned { pub trait Input: Clone + serde::Serialize + serde::de::DeserializeOwned + Debug {
#[cfg(feature = "std")] #[cfg(feature = "std")]
/// Write this input to the file /// Write this input to the file
fn to_file<P>(&self, path: P) -> Result<(), AflError> fn to_file<P>(&self, path: P) -> Result<(), AflError>

View File

@ -2,8 +2,6 @@
extern crate alloc; extern crate alloc;
use alloc::boxed::Box;
#[cfg(feature = "std")] #[cfg(feature = "std")]
use std::io::stderr; use std::io::stderr;