Skip to content

Commit

Permalink
Fix spurious fuzzing failures
Browse files Browse the repository at this point in the history
  • Loading branch information
cberner committed Nov 7, 2023
1 parent fc150a2 commit 409fc08
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions fuzz/fuzz_targets/fuzz_redb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ fn handle_multimap_table_op(op: &FuzzOperation, reference: &mut BTreeMap<u64, BT
assert_eq!(*ref_key, key.value());
assert_multimap_value_eq(value_iter, Some(ref_values))?;
}
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!();
}
}
}

Expand Down Expand Up @@ -387,7 +390,10 @@ fn handle_table_op(op: &FuzzOperation, reference: &mut BTreeMap<u64, usize>, 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;
Expand Down Expand Up @@ -442,7 +448,10 @@ fn handle_table_op(op: &FuzzOperation, reference: &mut BTreeMap<u64, usize>, 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!();
}
}
}

Expand Down Expand Up @@ -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(())
}
Expand Down

0 comments on commit 409fc08

Please sign in to comment.