-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5ced93
commit ba2de06
Showing
6 changed files
with
104 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
unstable_features = true | ||
|
||
comment_width = 100 | ||
wrap_comments = true | ||
|
||
imports_granularity = "Crate" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#![no_main] | ||
use acid_alloc_hater::SlabSubject; | ||
use alloc_hater::AllocatorOp; | ||
use arbitrary::{Arbitrary, Unstructured}; | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
const MAX_NUM_BLOCKS: usize = 1024; | ||
const MAX_BLOCK_SIZE: usize = 1024; | ||
|
||
#[derive(Clone, Debug)] | ||
struct Args { | ||
block_size: usize, | ||
num_blocks: usize, | ||
ops: Vec<AllocatorOp>, | ||
} | ||
|
||
impl Arbitrary<'_> for Args { | ||
fn arbitrary(un: &mut Unstructured) -> arbitrary::Result<Args> { | ||
let block_size = usize::arbitrary(un)? % MAX_BLOCK_SIZE; | ||
let num_blocks = usize::arbitrary(un)? % MAX_NUM_BLOCKS; | ||
let ops = Vec::arbitrary(un)?; | ||
|
||
Ok(Args { | ||
block_size, | ||
num_blocks, | ||
ops, | ||
}) | ||
} | ||
} | ||
|
||
fuzz_target!(|args: Args| { | ||
let Args { | ||
block_size, | ||
num_blocks, | ||
ops, | ||
} = args; | ||
|
||
let mut slab = match SlabSubject::new(args.block_size, args.num_blocks) { | ||
Ok(s) => s, | ||
Err(_) => return, | ||
}; | ||
|
||
let mut eval = alloc_hater::Evaluator::new(slab); | ||
eval.evaluate(ops).unwrap(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters