From 3b45e8614d45a44ebe6edf7b7939805f692f90ec Mon Sep 17 00:00:00 2001 From: Alice Ryhl Date: Tue, 11 Apr 2023 10:40:10 +0200 Subject: [PATCH] stream: update StreamMap fuzz test (#5600) 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. --- tokio-stream/fuzz/fuzz_targets/fuzz_stream_map.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tokio-stream/fuzz/fuzz_targets/fuzz_stream_map.rs b/tokio-stream/fuzz/fuzz_targets/fuzz_stream_map.rs index 4c3a2d04aaf..36c67659d79 100644 --- a/tokio-stream/fuzz/fuzz_targets/fuzz_stream_map.rs +++ b/tokio-stream/fuzz/fuzz_targets/fuzz_stream_map.rs @@ -28,7 +28,7 @@ fn pin_box + 'static, U>(s: T) -> Pin { @@ -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 {