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

Function test_mlock_with

tests/mm/mlock.rs:31–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29#[cfg(linux_kernel)]
30#[test]
31fn test_mlock_with() {
32 let mut buf = vec![0_u8; 4096];
33
34 unsafe {
35 match rustix::mm::mlock_with(
36 buf.as_mut_ptr().cast::<c_void>(),
37 buf.len(),
38 rustix::mm::MlockFlags::empty(),
39 ) {
40 Ok(()) => rustix::mm::munlock(buf.as_mut_ptr().cast::<c_void>(), buf.len()).unwrap(),
41 // Tests won't always have enough memory or permissions, and that's ok.
42 Err(rustix::io::Errno::PERM | rustix::io::Errno::NOMEM | rustix::io::Errno::NOSYS) => {}
43 // But they shouldn't fail otherwise.
44 Err(other) => panic!("{:?}", other),
45 }
46 }
47}
48
49#[cfg(linux_kernel)]
50#[test]

Callers

nothing calls this directly

Calls 4

mlock_withFunction · 0.50
munlockFunction · 0.50
as_mut_ptrMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected