removed _rr funcs
This commit is contained in:
parent
59e61c2e3d
commit
194ac619be
@ -35,13 +35,13 @@ where
|
||||
|
||||
/// Add an entry to the corpus
|
||||
#[allow(unused_mut)]
|
||||
fn add(&mut self, mut entry: Rc<RefCell<Testcase<I>>>) {
|
||||
self.entries_mut().push(entry);
|
||||
fn add(&mut self, mut testcase: Rc<RefCell<Testcase<I>>>) {
|
||||
self.entries_mut().push(testcase);
|
||||
}
|
||||
|
||||
/// Add an input to the corpus
|
||||
fn add_input(&mut self, input: I) {
|
||||
self.add(Testcase::new_rr(input));
|
||||
self.add(Testcase::new(input.into()).into());
|
||||
}
|
||||
|
||||
/// Removes an entry from the corpus, returning it if it was present.
|
||||
@ -368,7 +368,7 @@ mod tests {
|
||||
let rand: Rc<_> = DefaultRand::preseeded().into();
|
||||
let mut q = QueueCorpus::new(OnDiskCorpus::new(&rand, PathBuf::from("fancy/path")));
|
||||
let i = BytesInput::new(vec![0; 4]);
|
||||
let t = Testcase::with_filename_rr(i, PathBuf::from("fancyfile"));
|
||||
let t: Rc<_> = Testcase::with_filename(i, PathBuf::from("fancyfile")).into();
|
||||
q.add(t);
|
||||
let filename = q
|
||||
.next()
|
||||
|
@ -5,6 +5,7 @@ use crate::AflError;
|
||||
|
||||
use alloc::rc::Rc;
|
||||
use core::cell::RefCell;
|
||||
use core::convert::Into;
|
||||
use hashbrown::HashMap;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
@ -113,6 +114,16 @@ where
|
||||
metadatas: HashMap<&'static str, Box<dyn TestcaseMetadata>>,
|
||||
}
|
||||
|
||||
impl<I> Into<Rc<RefCell<Self>>> for Testcase<I>
|
||||
where
|
||||
I: Input,
|
||||
{
|
||||
fn into(self) -> Rc<RefCell<Self>> {
|
||||
Rc::new(RefCell::new(self))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Impl of a testcase
|
||||
impl<I> Testcase<I>
|
||||
where
|
||||
@ -181,16 +192,4 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new Testcase instace given an input behind a Rc RefCell
|
||||
pub fn new_rr<T>(input: T) -> Rc<RefCell<Self>>
|
||||
where
|
||||
T: Into<I>,
|
||||
{
|
||||
Rc::new(RefCell::new(Self::new(input.into())))
|
||||
}
|
||||
|
||||
/// Create a new Testcase instace given an input and a filename behind a Rc RefCell
|
||||
pub fn with_filename_rr(input: I, filename: PathBuf) -> Rc<RefCell<Self>> {
|
||||
Rc::new(RefCell::new(Self::with_filename(input, filename)))
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
//! The engine is the core piece of every good fuzzer
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::rc::Rc;
|
||||
use core::cell::RefCell;
|
||||
|
||||
use crate::corpus::Corpus;
|
||||
use crate::feedbacks::Feedback;
|
||||
use crate::inputs::Input;
|
||||
@ -82,9 +79,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_rr() -> Rc<RefCell<Self>> {
|
||||
Rc::new(RefCell::new(Self::new()))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -110,13 +104,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_engine() {
|
||||
// TODO: Replace _rr with .Into traits
|
||||
let rand: Rc<_> = DefaultRand::preseeded().into();
|
||||
|
||||
let mut corpus = InMemoryCorpus::<BytesInput, _>::new(&rand);
|
||||
let testcase = Testcase::new_rr(vec![0; 4]);
|
||||
let testcase = Testcase::new(BytesInput::new(vec![0; 4])).into();
|
||||
corpus.add(testcase);
|
||||
let executor: Rc<RefCell<InMemoryExecutor<BytesInput>>> = InMemoryExecutor::new_rr(harness);
|
||||
let executor: Rc<RefCell<InMemoryExecutor<BytesInput>>> = InMemoryExecutor::new(harness).into();
|
||||
let mut engine = DefaultEngine::new();
|
||||
let mut mutator = DefaultScheduledMutator::new(&rand);
|
||||
mutator.add_mutation(mutation_bitflip);
|
||||
|
@ -22,6 +22,15 @@ where
|
||||
feedbacks: Vec<Box<dyn Feedback<I>>>,
|
||||
}
|
||||
|
||||
impl<I> Into<Rc<RefCell<Self>>> for InMemoryExecutor<I>
|
||||
where
|
||||
I: Input,
|
||||
{
|
||||
fn into(self) -> Rc<RefCell<Self>> {
|
||||
Rc::new(RefCell::new(self))
|
||||
}
|
||||
}
|
||||
|
||||
static mut CURRENT_INMEMORY_EXECUTOR_PTR: *const c_void = ptr::null();
|
||||
|
||||
impl<I> Executor<I> for InMemoryExecutor<I>
|
||||
@ -90,9 +99,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_rr(harness_fn: HarnessFunction<I>) -> Rc<RefCell<Self>> {
|
||||
Rc::new(RefCell::new(Self::new(harness_fn)))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
@ -2,9 +2,8 @@ extern crate alloc;
|
||||
|
||||
use core::convert::From;
|
||||
|
||||
use core::convert::TryFrom;
|
||||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
use core::cell::RefCell;
|
||||
use alloc::rc::Rc;
|
||||
|
||||
use crate::inputs::{HasBytesVec, HasTargetBytes, Input};
|
||||
use crate::AflError;
|
||||
@ -25,6 +24,14 @@ impl Input for BytesInput {
|
||||
}
|
||||
}
|
||||
|
||||
/// Rc Ref-cell from Input
|
||||
impl Into<Rc<RefCell<Self>>> for BytesInput {
|
||||
fn into(self) -> Rc<RefCell<Self>> {
|
||||
Rc::new(RefCell::new(self))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl HasBytesVec for BytesInput {
|
||||
fn bytes(&self) -> &Vec<u8> {
|
||||
&self.bytes
|
||||
|
@ -53,7 +53,7 @@ where
|
||||
self.mutator_mut().post_exec(interesting, i as i32)?;
|
||||
|
||||
if interesting {
|
||||
corpus.add(Testcase::new_rr(input_tmp));
|
||||
corpus.add(Testcase::new(input_tmp).into());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -109,7 +109,6 @@ impl Rand for Xoshiro256StarRand {
|
||||
}
|
||||
}
|
||||
|
||||
use std::convert::Into;
|
||||
impl Into<Rc<RefCell<Self>>> for Xoshiro256StarRand {
|
||||
fn into(self) -> Rc<RefCell<Self>> {
|
||||
Rc::new(RefCell::new(self))
|
||||
|
Loading…
x
Reference in New Issue
Block a user