From 7e5354df637c11516811abaa66f0a70eb524e28e Mon Sep 17 00:00:00 2001 From: Christopher Berner Date: Sun, 5 Nov 2023 17:47:13 -0800 Subject: [PATCH] Fix spurious fuzzing failures --- fuzz/fuzz_targets/fuzz_redb.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/fuzz/fuzz_targets/fuzz_redb.rs b/fuzz/fuzz_targets/fuzz_redb.rs index 4aafd210..2a55647d 100644 --- a/fuzz/fuzz_targets/fuzz_redb.rs +++ b/fuzz/fuzz_targets/fuzz_redb.rs @@ -294,7 +294,10 @@ fn handle_multimap_table_op(op: &FuzzOperation, reference: &mut BTreeMap, tab } drop(reference_iter); reference.retain(|x, _| *x < start || *x >= end); - assert!(iter.next().is_none()); + // This is basically assert!(iter.next().is_none()), but we also allow an Err such as a simulated IO error + if let Some(Ok((_, _))) = iter.next() { + panic!(); + } } FuzzOperation::DrainFilter { start_key, len, modulus, reversed } => { let start = start_key.value; @@ -442,7 +448,10 @@ fn handle_table_op(op: &FuzzOperation, reference: &mut BTreeMap, tab assert_eq!(*ref_key, key.value()); assert_eq!(*ref_value_len, value.value().len()); } - assert!(iter.next().is_none()); + // This is basically assert!(iter.next().is_none()), but we also allow an Err such as a simulated IO error + if let Some(Ok((_, _))) = iter.next() { + panic!(); + } } } @@ -660,7 +669,10 @@ fn assert_multimap_value_eq( assert_eq!(iter.next().unwrap()?.value().len(), *value); } } - assert!(iter.next().is_none()); + // This is basically assert!(iter.next().is_none()), but we also allow an Err such as a simulated IO error + if let Some(Ok(_)) = iter.next() { + panic!(); + } Ok(()) }