This repository has been archived on 2026-10-10. You can view files and clone it, but cannot push or open issues or pull requests.
molotov/crates/molotov-core/tests/mmap_test.rs

19 lines
707 B
Rust

// SPDX-License-Identifier: GPL-3.0-or-later
use molotov_core::mmap::MappedImage;
#[test]
fn test_page_alignment_helper() {
assert_eq!(MappedImage::page_align_down(4096), 4096);
assert_eq!(MappedImage::page_align_down(4097), 4096);
assert_eq!(MappedImage::page_align_up(4095), 4096);
assert_eq!(MappedImage::page_align_up(4096), 4096);
assert_eq!(MappedImage::page_align_up(4097), 8192);
}
#[test]
fn test_mmap_reservation_and_drop() {
let mapping = MappedImage::allocate_anonymous(65536).expect("Should mmap virtual address space");
assert!(!mapping.base_addr().is_null());
assert_eq!(mapping.size(), 65536);
// Dropping mapping unmaps memory automatically via RAII
}