add TimeStateMaximizerCorpusScheduler
This commit is contained in:
parent
71280b89af
commit
5176828dbb
@ -386,7 +386,8 @@ fn fuzz(
|
|||||||
|
|
||||||
// A minimization+queue policy to get testcasess from the corpus
|
// A minimization+queue policy to get testcasess from the corpus
|
||||||
// let scheduler = IndexesLenTimeMinimizerCorpusScheduler::new(PowerQueueCorpusScheduler::new());
|
// let scheduler = IndexesLenTimeMinimizerCorpusScheduler::new(PowerQueueCorpusScheduler::new());
|
||||||
let scheduler = QueueCorpusScheduler::new();
|
let scheduler = TimeStateMaximizerCorpusScheduler::new(QueueCorpusScheduler::new());
|
||||||
|
// let scheduler = QueueCorpusScheduler::new();
|
||||||
|
|
||||||
|
|
||||||
// A fuzzer with feedbacks and a corpus scheduler
|
// A fuzzer with feedbacks and a corpus scheduler
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
//! Sysstate referes to the State of a FreeRTOS fuzzing target
|
//! Sysstate referes to the State of a FreeRTOS fuzzing target
|
||||||
|
use std::collections::hash_map::DefaultHasher;
|
||||||
|
use libafl::bolts::HasRefCnt;
|
||||||
|
use libafl::bolts::AsSlice;
|
||||||
use std::hash::Hasher;
|
use std::hash::Hasher;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
@ -98,10 +101,38 @@ impl Hash for MiniFreeRTOSSystemState {
|
|||||||
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
|
||||||
pub struct FreeRTOSSystemStateMetadata {
|
pub struct FreeRTOSSystemStateMetadata {
|
||||||
inner: Vec<MiniFreeRTOSSystemState>,
|
inner: Vec<MiniFreeRTOSSystemState>,
|
||||||
|
indices: Vec<usize>, // Hashed enumeration of States
|
||||||
|
tcref: isize,
|
||||||
}
|
}
|
||||||
impl FreeRTOSSystemStateMetadata {
|
impl FreeRTOSSystemStateMetadata {
|
||||||
pub fn new(inner: Vec<MiniFreeRTOSSystemState>) -> Self{
|
pub fn new(inner: Vec<MiniFreeRTOSSystemState>) -> Self{
|
||||||
Self {inner: inner}
|
let tmp = inner.iter().enumerate().map(|x| compute_hash(x) as usize).collect();
|
||||||
|
Self {inner: inner, indices: tmp, tcref: 0}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn compute_hash<T>(obj: T) -> u64
|
||||||
|
where
|
||||||
|
T: Hash
|
||||||
|
{
|
||||||
|
let mut s = DefaultHasher::new();
|
||||||
|
obj.hash(&mut s);
|
||||||
|
s.finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsSlice<usize> for FreeRTOSSystemStateMetadata {
|
||||||
|
/// Convert the slice of system-states to a slice of hashes over enumerated states
|
||||||
|
fn as_slice(&self) -> &[usize] {
|
||||||
|
self.indices.as_slice()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl HasRefCnt for FreeRTOSSystemStateMetadata {
|
||||||
|
fn refcnt(&self) -> isize {
|
||||||
|
self.tcref
|
||||||
|
}
|
||||||
|
|
||||||
|
fn refcnt_mut(&mut self) -> &mut isize {
|
||||||
|
&mut self.tcref
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use crate::sysstate::FreeRTOSSystemStateMetadata;
|
||||||
use num_traits::PrimInt;
|
use num_traits::PrimInt;
|
||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
use core::cmp::Ordering::{Greater,Less,Equal};
|
use core::cmp::Ordering::{Greater,Less,Equal};
|
||||||
@ -509,6 +510,9 @@ where
|
|||||||
pub type LenTimeMaximizerCorpusScheduler<CS, I, S> =
|
pub type LenTimeMaximizerCorpusScheduler<CS, I, S> =
|
||||||
MinimizerCorpusScheduler<CS, MaxExecsLenFavFactor<I>, I, MapIndexesMetadata, S>;
|
MinimizerCorpusScheduler<CS, MaxExecsLenFavFactor<I>, I, MapIndexesMetadata, S>;
|
||||||
|
|
||||||
|
pub type TimeStateMaximizerCorpusScheduler<CS, I, S> =
|
||||||
|
MinimizerCorpusScheduler<CS, MaxExecsLenFavFactor<I>, I, FreeRTOSSystemStateMetadata, S>;
|
||||||
|
|
||||||
/// Multiply the testcase size with the execution time.
|
/// Multiply the testcase size with the execution time.
|
||||||
/// This favors small and quick testcases.
|
/// This favors small and quick testcases.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user