Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions crates/multitude/tests/bytemuck_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,69 +157,75 @@ fn try_alloc_slice_arc_ok() {
// stack cannot satisfy a 64 KiB-aligned frame. The non-slice
// `try_*_over_aligned_returns_err` siblings exercise the same
// alignment-rejection guard on every platform.
#[cfg(not(utc_backend))]
#[derive(Clone, Copy)]
#[repr(C, align(65536))]
struct OverAligned {
_data: u8,
}

// SAFETY: all-zeros is a valid OverAligned (it's just a u8 + padding).
#[cfg(not(utc_backend))]
unsafe impl Zeroable for OverAligned {}

#[test]
#[cfg(not(utc_backend))]
fn try_alloc_box_over_aligned_returns_err() {
let arena = Arena::new();
let result = arena.bytemuck().try_alloc_box::<OverAligned>();
assert!(result.is_err());
}

#[test]
#[cfg(not(utc_backend))]
fn try_alloc_arc_over_aligned_returns_err() {
let arena = Arena::new();
let result = arena.bytemuck().try_alloc_arc::<OverAligned>();
assert!(result.is_err());
}

#[test]
#[cfg(not(utc_backend))]
fn try_alloc_slice_box_over_aligned_returns_err() {
let arena = Arena::new();
let result = arena.bytemuck().try_alloc_slice_box::<OverAligned>(4);
assert!(result.is_err());
}

#[test]
#[cfg(not(utc_backend))]
fn try_alloc_slice_arc_over_aligned_returns_err() {
let arena = Arena::new();
let result = arena.bytemuck().try_alloc_slice_arc::<OverAligned>(4);
assert!(result.is_err());
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
#[should_panic = "arena allocation failed"]
fn alloc_box_panics_on_over_aligned() {
let arena = Arena::new();
let _ = arena.bytemuck().alloc_box::<OverAligned>();
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
#[should_panic = "arena allocation failed"]
fn alloc_arc_panics_on_over_aligned() {
let arena = Arena::new();
let _ = arena.bytemuck().alloc_arc::<OverAligned>();
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
#[should_panic = "arena allocation failed"]
fn alloc_slice_box_panics_on_over_aligned() {
let arena = Arena::new();
let _ = arena.bytemuck().alloc_slice_box::<OverAligned>(4);
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
#[should_panic = "arena allocation failed"]
fn alloc_slice_arc_panics_on_over_aligned() {
let arena = Arena::new();
Expand Down Expand Up @@ -256,14 +262,15 @@ fn try_alloc_ref_scalar_ok() {
}

#[test]
#[cfg(not(utc_backend))]
fn try_alloc_ref_over_aligned_returns_err() {
let arena = Arena::new();
let result = arena.bytemuck().try_alloc::<OverAligned>();
assert!(result.is_err());
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
#[should_panic = "arena allocation failed"]
fn alloc_ref_panics_on_over_aligned() {
let arena = Arena::new();
Expand Down Expand Up @@ -301,15 +308,15 @@ fn try_alloc_slice_ref_ok() {
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
fn try_alloc_slice_ref_over_aligned_returns_err() {
let arena = Arena::new();
let result = arena.bytemuck().try_alloc_slice::<OverAligned>(4);
assert!(result.is_err());
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
#[should_panic = "arena allocation failed"]
fn alloc_slice_ref_panics_on_over_aligned() {
let arena = Arena::new();
Expand Down
20 changes: 13 additions & 7 deletions crates/multitude/tests/zerocopy_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,66 +127,71 @@ fn try_alloc_slice_arc_ok() {
// stack cannot satisfy a 64 KiB-aligned frame. The non-slice
// `try_*_over_aligned_returns_err` siblings exercise the same
// alignment-rejection guard on every platform.
#[cfg(not(utc_backend))]
#[derive(FromZeros)]
#[repr(C, align(65536))]
struct OverAligned {
_data: u8,
}

#[test]
#[cfg(not(utc_backend))]
fn try_alloc_box_over_aligned_returns_err() {
let arena = Arena::new();
let result = arena.zerocopy().try_alloc_box::<OverAligned>();
assert!(result.is_err());
}

#[test]
#[cfg(not(utc_backend))]
fn try_alloc_arc_over_aligned_returns_err() {
let arena = Arena::new();
let result = arena.zerocopy().try_alloc_arc::<OverAligned>();
assert!(result.is_err());
}

#[test]
#[cfg(not(utc_backend))]
fn try_alloc_slice_box_over_aligned_returns_err() {
let arena = Arena::new();
let result = arena.zerocopy().try_alloc_slice_box::<OverAligned>(4);
assert!(result.is_err());
}

#[test]
#[cfg(not(utc_backend))]
fn try_alloc_slice_arc_over_aligned_returns_err() {
let arena = Arena::new();
let result = arena.zerocopy().try_alloc_slice_arc::<OverAligned>(4);
assert!(result.is_err());
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
#[should_panic = "arena allocation failed"]
fn alloc_box_panics_on_over_aligned() {
let arena = Arena::new();
let _ = arena.zerocopy().alloc_box::<OverAligned>();
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
#[should_panic = "arena allocation failed"]
fn alloc_arc_panics_on_over_aligned() {
let arena = Arena::new();
let _ = arena.zerocopy().alloc_arc::<OverAligned>();
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
#[should_panic = "arena allocation failed"]
fn alloc_slice_box_panics_on_over_aligned() {
let arena = Arena::new();
let _ = arena.zerocopy().alloc_slice_box::<OverAligned>(4);
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
#[should_panic = "arena allocation failed"]
fn alloc_slice_arc_panics_on_over_aligned() {
let arena = Arena::new();
Expand Down Expand Up @@ -223,14 +228,15 @@ fn try_alloc_ref_scalar_ok() {
}

#[test]
#[cfg(not(utc_backend))]
fn try_alloc_ref_over_aligned_returns_err() {
let arena = Arena::new();
let result = arena.zerocopy().try_alloc::<OverAligned>();
assert!(result.is_err());
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
#[should_panic = "arena allocation failed"]
fn alloc_ref_panics_on_over_aligned() {
let arena = Arena::new();
Expand Down Expand Up @@ -268,15 +274,15 @@ fn try_alloc_slice_ref_ok() {
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
fn try_alloc_slice_ref_over_aligned_returns_err() {
let arena = Arena::new();
let result = arena.zerocopy().try_alloc_slice::<OverAligned>(4);
assert!(result.is_err());
}

#[test]
#[cfg(not(target_os = "windows"))]
#[cfg(all(not(target_os = "windows"), not(utc_backend)))]
#[should_panic = "arena allocation failed"]
fn alloc_slice_ref_panics_on_over_aligned() {
let arena = Arena::new();
Expand Down
Loading