From 7d6959c339068384aa5584008628a2b8401f3c1a Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Wed, 27 Sep 2023 10:50:13 -0700 Subject: [PATCH] fix: use a smaller `CustomConfig` for 32-bit tests This way, the custom-config tests from PR #80 can still be run on 32-bit targets. Fixes #82 --- src/tests/custom_config.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/tests/custom_config.rs b/src/tests/custom_config.rs index 383387b..533cd7d 100644 --- a/src/tests/custom_config.rs +++ b/src/tests/custom_config.rs @@ -3,9 +3,11 @@ #![cfg(not(loom))] -use crate::{Config, Slab}; +use crate::{cfg::CfgPrivate, Config, Slab}; struct CustomConfig; + +#[cfg(target_pointer_width = "64")] impl Config for CustomConfig { const INITIAL_PAGE_SIZE: usize = 32; const MAX_PAGES: usize = 15; @@ -13,6 +15,14 @@ impl Config for CustomConfig { const RESERVED_BITS: usize = 24; } +#[cfg(not(target_pointer_width = "64"))] +impl Config for CustomConfig32 { + const INITIAL_PAGE_SIZE: usize = 16; + const MAX_PAGES: usize = 7; + const MAX_THREADS: usize = 128; + const RESERVED_BITS: usize = 12; +} + // We should repeat actions several times to detect invalid lifecycle changes. const ITERS: u64 = 5; @@ -29,6 +39,8 @@ fn slab_eq(mut lhs: Slab, mut rhs: Slab) { /// Initially, it revealed bugs in the `Slot::release_with()` implementation. #[test] fn insert_remove() { + eprintln!("bits={}; config={:#?}", usize::BITS, CustomConfig::debug()); + let default_slab = Slab::::new(); let custom_slab = Slab::::new_with_config::(); @@ -47,6 +59,8 @@ fn insert_remove() { /// Initially, it revealed bugs in the `Slot::get()` implementation. #[test] fn double_get() { + eprintln!("bits={}; config={:#?}", usize::BITS, CustomConfig::debug()); + let default_slab = Slab::::new(); let custom_slab = Slab::::new_with_config::();