From af5b976ba8c5c09868f8a0b80b887e844c12d1e7 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Thu, 28 Nov 2024 15:13:15 -0800 Subject: [PATCH] test: add windows mapsize test that should fail WIP: fix this! Signed-off-by: William Casarin --- src/ndb.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/ndb.rs b/src/ndb.rs index 8294af8..fa04f1f 100644 --- a/src/ndb.rs +++ b/src/ndb.rs @@ -448,4 +448,35 @@ mod tests { assert_eq!(note.kind(), 1); } } + + #[test] + #[cfg(target_os = "windows")] + fn test_windows_large_mapsize() { + use std::{fs, path::Path}; + + let db = "target/testdbs/event_works"; + test_util::cleanup_db(&db); + + { + // 32 TiB should be way too big for CI + let config = Config::new().set_mapsize(1024usize * 1024usize * 1024usize * 1024usize * 32usize); + let ndb = Ndb::new(db, &config); + assert!(ndb.is_ok()); + } + + let file_len = fs::metadata(Path::new(db).join("data.mdb")) + .expect("metadata") + .len(); + + assert!(file_len > 0); + + if cfg!(target_os = "windows") { + assert_ne!(file_len, 1048576); + } else { + assert!(file_len < 1024u64 * 1024u64); + } + + // If the file size is the default mapsize on windows, this is a bug! + + } }