MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / test_mremap

Function test_mremap

tests/mm/mmap.rs:171–189  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

169#[cfg(any(target_os = "emscripten", target_os = "linux"))]
170#[test]
171fn test_mremap() {
172 use rustix::mm::{mmap_anonymous, mremap, munmap, MapFlags, MremapFlags, ProtFlags};
173 use std::ptr::null_mut;
174
175 unsafe {
176 let addr = mmap_anonymous(null_mut(), 8192, ProtFlags::READ, MapFlags::PRIVATE).unwrap();
177
178 assert_eq!(
179 mremap(addr, 4096, 16384, MremapFlags::empty()),
180 Err(rustix::io::Errno::NOMEM)
181 );
182 let new = mremap(addr, 4096, 16384, MremapFlags::MAYMOVE).unwrap();
183 assert_ne!(new, addr);
184 assert!(!new.is_null());
185
186 munmap(new, 16384).unwrap();
187 munmap(addr.offset(4096), 4096).unwrap();
188 }
189}

Callers

nothing calls this directly

Calls 4

mmap_anonymousFunction · 0.50
mremapFunction · 0.50
munmapFunction · 0.50
offsetMethod · 0.45

Tested by

no test coverage detected