Skip to content

Commit

Permalink
Fix the fuzzers that stopped compiling (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubadamw committed Jul 28, 2020
1 parent b4da559 commit 5758549
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
3 changes: 1 addition & 2 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ publish = false
tinyvec = { path = "..", features = ["alloc", "nightly_slice_partition_dedup"] }
rutenspitz = "0.2"
honggfuzz = "0.5.45"
arbitrary = "0.2.0"
arbitrary = { version = "0.4.5", features = ["derive"] }
better-panic = "0.2.0"
derive_arbitrary = "0.2.0"
4 changes: 2 additions & 2 deletions fuzz/src/arb_range.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use arbitrary::{Arbitrary, Unstructured};
use arbitrary::{Arbitrary, Result, Unstructured};
use std::ops::{
Bound, Range, RangeBounds, RangeFrom, RangeInclusive, RangeTo,
RangeToInclusive,
Expand Down Expand Up @@ -50,7 +50,7 @@ impl<T> RangeBounds<T> for ArbRange<T> {
}

impl<T: Arbitrary> Arbitrary for ArbRange<T> {
fn arbitrary<U: Unstructured + ?Sized>(u: &mut U) -> Result<Self, U::Error> {
fn arbitrary(u: &mut Unstructured) -> Result<Self> {
let variant = u8::arbitrary(u)? % 5;
Ok(match variant {
0 => ArbRange::Range(T::arbitrary(u)?..T::arbitrary(u)?),
Expand Down
9 changes: 3 additions & 6 deletions fuzz/src/bin/arrayish.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use arbitrary_model_tests::arbitrary_stateful_operations;
use derive_arbitrary::Arbitrary;
use honggfuzz::fuzz;
use std::{
fmt::Debug,
iter::FromIterator,
ops::{Bound, RangeBounds},
};
use rutenspitz::arbitrary_stateful_operations;

use tinyvec::ArrayVec;
use tinyvec_fuzz::ArbRange;
Expand Down Expand Up @@ -84,12 +83,10 @@ arbitrary_stateful_operations! {
}
}

const MAX_RING_SIZE: usize = 16_384;

fn fuzz_cycle(data: &[u8]) -> Result<(), ()> {
use arbitrary::{Arbitrary, FiniteBuffer};
use arbitrary::{Arbitrary, Unstructured};

let mut ring = FiniteBuffer::new(&data, MAX_RING_SIZE).map_err(|_| ())?;
let mut ring = Unstructured::new(&data);

let mut model = Vec::<u16>::default();
let mut tested: ArrayVec<[u16; 32]> = ArrayVec::new();
Expand Down
9 changes: 3 additions & 6 deletions fuzz/src/bin/tinyvec.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use arbitrary_model_tests::arbitrary_stateful_operations;
use derive_arbitrary::Arbitrary;
use honggfuzz::fuzz;
use std::{
fmt::Debug,
iter::FromIterator,
ops::{Bound, RangeBounds},
};
use rutenspitz::arbitrary_stateful_operations;

use tinyvec::TinyVec;
use tinyvec_fuzz::ArbRange;
Expand Down Expand Up @@ -82,12 +81,10 @@ arbitrary_stateful_operations! {
}
}

const MAX_RING_SIZE: usize = 16_384;

fn fuzz_cycle(data: &[u8]) -> Result<(), ()> {
use arbitrary::{Arbitrary, FiniteBuffer};
use arbitrary::{Arbitrary, Unstructured};

let mut ring = FiniteBuffer::new(&data, MAX_RING_SIZE).map_err(|_| ())?;
let mut ring = Unstructured::new(&data);

let mut model = Vec::<u16>::default();
let mut tested: TinyVec<[u16; 32]> = TinyVec::new();
Expand Down

0 comments on commit 5758549

Please sign in to comment.