1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
use std::fs::OpenOptions; use std::io::Write; use std::path::Path; use memmap::{MmapMut, MmapOptions}; pub fn setup_replica(data: &[u8], replica_path: &Path) -> MmapMut { let mut f = OpenOptions::new() .read(true) .write(true) .create(true) .open(replica_path) .expect("Failed to create replica"); f.write_all(data).expect("Failed to write data to replica"); unsafe { MmapOptions::new() .map_mut(&f) .expect("Failed to back memory map with tempfile") } } #[macro_export] macro_rules! table_tests { ($property_test_func:ident { $( $(#[$attr:meta])* $test_name:ident( $( $param:expr ),* ); )+ }) => { $( $(#[$attr])* #[test] fn $test_name() { $property_test_func($( $param ),* ) } )+ } }