Skip to content

Commit

Permalink
Add region size fuzzing
Browse files Browse the repository at this point in the history
  • Loading branch information
cberner committed Jun 12, 2023
1 parent 076bdda commit c57339f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fuzz/fuzz_targets/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use rand::SeedableRng;

const MAX_CRASH_OPS: u64 = 20;
const MAX_CACHE_SIZE: usize = 100_000_000;
// Limit values to 10MiB
const MAX_VALUE_SIZE: usize = 10_000_000;
// Limit values to 100KiB
const MAX_VALUE_SIZE: usize = 100_000;
const KEY_SPACE: u64 = 1_000_000;
pub const MAX_SAVEPOINTS: usize = 6;

Expand Down Expand Up @@ -135,4 +135,6 @@ pub(crate) struct FuzzConfig {
pub crash_after_ops: BoundedU64<MAX_CRASH_OPS>,
pub transactions: Vec<FuzzTransaction>,
pub page_size: PowerOfTwoBetween<9, 14>,
// Must not be too small, otherwise persistent savepoints won't fit into a region
pub region_size: PowerOfTwoBetween<20, 30>,
}
3 changes: 3 additions & 0 deletions fuzz/fuzz_targets/fuzz_redb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ fn exec_table_crash_support<T: Clone>(config: &FuzzConfig, apply: fn(&Database,
let mut db = Database::builder()
.set_page_size(config.page_size.value)
.set_cache_size(config.cache_size.value)
.set_region_size(config.region_size.value as u64)
.create(redb_file.path())
.unwrap();
db.set_crash_countdown(config.crash_after_ops.value);
Expand Down Expand Up @@ -331,6 +332,7 @@ fn exec_table_crash_support<T: Clone>(config: &FuzzConfig, apply: fn(&Database,
db = Database::builder()
.set_page_size(config.page_size.value)
.set_cache_size(config.cache_size.value)
.set_region_size(config.region_size.value as u64)
.create(redb_file.path())
.unwrap();
} else {
Expand All @@ -356,6 +358,7 @@ fn exec_table_crash_support<T: Clone>(config: &FuzzConfig, apply: fn(&Database,
db = Database::builder()
.set_page_size(config.page_size.value)
.set_cache_size(config.cache_size.value)
.set_region_size(config.region_size.value as u64)
.create(redb_file.path())
.unwrap();
} else {
Expand Down

0 comments on commit c57339f

Please sign in to comment.