Skip to content

Commit

Permalink
stream: update StreamMap fuzz test (tokio-rs#5600)
Browse files Browse the repository at this point in the history
This fuzz test touches some quadratic time code paths. This changes the
test to limit the test size so that the test doesn't time out.
  • Loading branch information
Darksonn committed Apr 11, 2023
1 parent b02c550 commit 3b45e86
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tokio-stream/fuzz/fuzz_targets/fuzz_stream_map.rs
Expand Up @@ -28,7 +28,7 @@ fn pin_box<T: Stream<Item = U> + 'static, U>(s: T) -> Pin<Box<dyn Stream<Item =
Box::pin(s)
}

fuzz_target!(|data: &[u8]| {
fuzz_target!(|data: [bool; 64]| {
use std::task::{Context, Poll};

struct DidPoll<T> {
Expand All @@ -45,11 +45,12 @@ fuzz_target!(|data: &[u8]| {
}
}

for _ in 0..10 {
// Try the test with each possible length.
for len in 0..data.len() {
let mut map = task::spawn(StreamMap::new());
let mut expect = 0;

for (i, is_empty) in data.iter().map(|x| *x != 0).enumerate() {
for (i, is_empty) in data[..len].iter().copied().enumerate() {
let inner = if is_empty {
pin_box(stream::empty::<()>())
} else {
Expand Down

0 comments on commit 3b45e86

Please sign in to comment.