summaryrefslogtreecommitdiff
path: root/test/sys
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2021-09-12 10:51:28 +0100
committerDavid Carlier <devnexen@gmail.com>2021-09-12 17:38:45 +0100
commita477541d781d57f837ef2ce1d9b80a24c2a2798b (patch)
tree672d9f2657fa89b62739d032e7e1e758fe549758 /test/sys
parentbf4f2738c9b4ad2ec1a2277358f94240f69fb8c8 (diff)
downloadnix-a477541d781d57f837ef2ce1d9b80a24c2a2798b.zip
mman module netbsd additions.
Diffstat (limited to 'test/sys')
-rw-r--r--test/sys/test_mman.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/test/sys/test_mman.rs b/test/sys/test_mman.rs
index 152fff69..4d140948 100644
--- a/test/sys/test_mman.rs
+++ b/test/sys/test_mman.rs
@@ -20,7 +20,7 @@ fn test_mmap_anonymous() {
}
#[test]
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "linux", target_os = "netbsd"))]
fn test_mremap_grow() {
const ONE_K : size_t = 1024;
let slice : &mut[u8] = unsafe {
@@ -35,9 +35,14 @@ fn test_mremap_grow() {
assert_eq !(slice[ONE_K - 1], 0xFF);
let slice : &mut[u8] = unsafe {
+ #[cfg(target_os = "linux")]
let mem = mremap(slice.as_mut_ptr() as * mut c_void, ONE_K, 10 * ONE_K,
MRemapFlags::MREMAP_MAYMOVE, None)
.unwrap();
+ #[cfg(target_os = "netbsd")]
+ let mem = mremap(slice.as_mut_ptr() as * mut c_void, ONE_K, 10 * ONE_K,
+ MRemapFlags::MAP_REMAPDUP, None)
+ .unwrap();
std::slice::from_raw_parts_mut(mem as * mut u8, 10 * ONE_K)
};
@@ -51,7 +56,7 @@ fn test_mremap_grow() {
}
#[test]
-#[cfg(target_os = "linux")]
+#[cfg(any(target_os = "linux", target_os = "netbsd"))]
fn test_mremap_shrink() {
const ONE_K : size_t = 1024;
let slice : &mut[u8] = unsafe {
@@ -66,11 +71,16 @@ fn test_mremap_shrink() {
assert_eq !(slice[ONE_K - 1], 0xFF);
let slice : &mut[u8] = unsafe {
+ #[cfg(target_os = "linux")]
let mem = mremap(slice.as_mut_ptr() as * mut c_void, 10 * ONE_K, ONE_K,
MRemapFlags::empty(), None)
.unwrap();
// Since we didn't supply MREMAP_MAYMOVE, the address should be the
// same.
+ #[cfg(target_os = "linux")]
+ let mem = mremap(slice.as_mut_ptr() as * mut c_void, 10 * ONE_K, ONE_K,
+ MRemapFlags::MAP_FIXED), None)
+ .unwrap();
assert_eq !(mem, slice.as_mut_ptr() as * mut c_void);
std::slice::from_raw_parts_mut(mem as * mut u8, ONE_K)
};