Skip to content

Commit c466821

Browse files
committed
fix CI: note that many allocators zero init on macos-latest
1 parent 943a736 commit c466821

File tree

8 files changed

+31
-11
lines changed

8 files changed

+31
-11
lines changed

src/allocator/alloc/global.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,13 @@ unsafe impl core::alloc::GlobalAlloc for Global {
197197

198198

199199

200+
#[cfg(test)] const GLOBAL_ALLOC_ZERO_INITS : bool = cfg!(any(
201+
target_os = "linux", // from the start of `ialloc` on CI and WSL
202+
target_os = "macos", // github's `macos-11` runners didn't zero init, but `macos-14`(? via `macos-latest`) does.
203+
));
204+
200205
#[test] fn fat_alignment() { fat::test::alignment(Global) }
201206
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(Global) }
202-
#[test] fn fat_uninit() { if !cfg!(target_os = "linux") { unsafe { fat::test::uninit_alloc_unsound(Global) } } }
207+
#[test] fn fat_uninit() { if !GLOBAL_ALLOC_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(Global) } } }
203208
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(Global) }
204209
#[test] fn fat_zst_support() { fat::test::zst_supported_accurate(Global) }

src/allocator/c/aligned_malloc.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,13 @@ mod ffi {
259259

260260

261261

262+
#[cfg(test)] const ALIGNED_ALLOC_ZERO_INITS : bool = cfg!(any(
263+
target_os = "linux", // from the start of `ialloc` on CI and WSL
264+
target_os = "macos", // github's `macos-11` runners didn't zero init, but `macos-14`(? via `macos-latest`) does.
265+
));
266+
262267
#[test] fn fat_alignment() { fat::test::alignment(AlignedMalloc) }
263268
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(AlignedMalloc) }
264-
#[test] fn fat_uninit() { if !cfg!(target_os = "linux") { unsafe { fat::test::uninit_alloc_unsound(AlignedMalloc) } } } // malloc returns zeroed memory on some platforms
269+
#[test] fn fat_uninit() { if !ALIGNED_ALLOC_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(AlignedMalloc) } } }
265270
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(AlignedMalloc) }
266271
#[test] fn fat_zst_support() { fat::test::zst_supported_conservative(AlignedMalloc) }

src/allocator/c/malloc.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,19 +187,24 @@ unsafe impl thin::SizeOfDebug for Malloc {
187187

188188

189189

190+
#[cfg(test)] const MALLOC_ZERO_INITS : bool = cfg!(any(
191+
target_os = "linux", // from the start of `ialloc` on CI and WSL
192+
target_os = "macos", // github's `macos-11` runners didn't zero init, but `macos-14`(? via `macos-latest`) does.
193+
));
194+
190195
#[test] fn thin_alignment() { thin::test::alignment(Malloc) }
191196
#[test] fn thin_edge_case_sizes() { thin::test::edge_case_sizes(Malloc) }
192197
#[test] fn thin_nullable() { thin::test::nullable(Malloc) }
193198
#[test] fn thin_size() { thin::test::size_over_alloc(Malloc) }
194-
#[test] fn thin_uninit() { if !cfg!(target_os = "linux") { unsafe { thin::test::uninit_alloc_unsound(Malloc) } } } // malloc returns zeroed memory on some platforms
199+
#[test] fn thin_uninit() { if !MALLOC_ZERO_INITS { unsafe { thin::test::uninit_alloc_unsound(Malloc) } } }
195200
#[test] fn thin_zeroed() { thin::test::zeroed_alloc(Malloc) }
196201
#[test] fn thin_zst_support() { thin::test::zst_supported_conservative(Malloc) }
197202
#[test] fn thin_zst_support_dangle() { thin::test::zst_supported_conservative(crate::allocator::adapt::DangleZst(Malloc)) }
198203
#[test] fn thin_zst_support_alloc() { thin::test::zst_supported_conservative(crate::allocator::adapt::AllocZst(Malloc)) }
199204

200205
#[test] fn fat_alignment() { fat::test::alignment(Malloc) }
201206
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(Malloc) }
202-
#[test] fn fat_uninit() { if !cfg!(target_os = "linux") { unsafe { fat::test::uninit_alloc_unsound(Malloc) } } } // malloc returns zeroed memory on some platforms
207+
#[test] fn fat_uninit() { if !MALLOC_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(Malloc) } } }
203208
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(Malloc) }
204209
#[test] fn fat_zst_support() { fat::test::zst_supported_conservative(Malloc) }
205210
#[test] fn fat_zst_support_dangle() { fat::test::zst_supported_conservative(crate::allocator::adapt::DangleZst(Malloc)) }

src/allocator/cpp/new_delete.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,20 @@ unsafe impl fat::Realloc for NewDelete {}
9191

9292

9393

94+
#[cfg(test)] pub(crate) const OPERATOR_NEW_ZERO_INITS : bool = cfg!(any(
95+
target_os = "linux", // from the start of `ialloc` on CI and WSL
96+
target_os = "macos", // github's `macos-11` runners didn't zero init, but `macos-14`(? via `macos-latest`) does.
97+
));
98+
9499
#[test] fn thin_alignment() { thin::test::alignment(NewDelete) }
95100
#[test] fn thin_edge_case_sizes() { thin::test::edge_case_sizes(NewDelete) }
96101
#[test] fn thin_nullable() { thin::test::nullable(NewDelete) }
97-
#[test] fn thin_uninit() { if !cfg!(target_os = "linux") { unsafe { thin::test::uninit_alloc_unsound(NewDelete) } } } // `::operator new` returns zeroed memory on some platforms
102+
#[test] fn thin_uninit() { if !OPERATOR_NEW_ZERO_INITS { unsafe { thin::test::uninit_alloc_unsound(NewDelete) } } }
98103
#[test] fn thin_zeroed() { thin::test::zeroed_alloc(NewDelete) }
99104
#[test] fn thin_zst_support() { thin::test::zst_supported_conservative(NewDelete) }
100105

101106
#[test] fn fat_alignment() { fat::test::alignment(NewDelete) }
102107
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(NewDelete) }
103-
#[test] fn fat_uninit() { if !cfg!(target_os = "linux") { unsafe { fat::test::uninit_alloc_unsound(NewDelete) } } }
108+
#[test] fn fat_uninit() { if !OPERATOR_NEW_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(NewDelete) } } }
104109
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(NewDelete) }
105110
#[test] fn fat_zst_support() { fat::test::zst_supported_conservative(NewDelete) }

src/allocator/cpp/new_delete_aligned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ unsafe impl fat::Realloc for NewDeleteAligned {}
8181

8282
#[test] fn fat_alignment() { fat::test::alignment(NewDeleteAligned) }
8383
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(NewDeleteAligned) }
84-
#[test] fn fat_uninit() { if !cfg!(target_os = "linux") { unsafe { fat::test::uninit_alloc_unsound(NewDeleteAligned) } } }
84+
#[test] fn fat_uninit() { if !allocator::cpp::OPERATOR_NEW_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(NewDeleteAligned) } } }
8585
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(NewDeleteAligned) }
8686
#[test] fn fat_zst_support() { fat::test::zst_supported_conservative(NewDeleteAligned) }

src/allocator/cpp/new_delete_array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ unsafe impl fat::Realloc for NewDeleteArray {}
9494
#[test] fn thin_alignment() { thin::test::alignment(NewDeleteArray) }
9595
#[test] fn thin_edge_case_sizes() { thin::test::edge_case_sizes(NewDeleteArray) }
9696
#[test] fn thin_nullable() { thin::test::nullable(NewDeleteArray) }
97-
#[test] fn thin_uninit() { if !cfg!(target_os = "linux") { unsafe { thin::test::uninit_alloc_unsound(NewDeleteArray) } } } // `::operator new[]` returns zeroed memory on some platforms
97+
#[test] fn thin_uninit() { if !allocator::cpp::OPERATOR_NEW_ZERO_INITS { unsafe { thin::test::uninit_alloc_unsound(NewDeleteArray) } } }
9898
#[test] fn thin_zeroed() { thin::test::zeroed_alloc(NewDeleteArray) }
9999
#[test] fn thin_zst_support() { thin::test::zst_supported_conservative(NewDeleteArray) }
100100

101101
#[test] fn fat_alignment() { fat::test::alignment(NewDeleteArray) }
102102
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(NewDeleteArray) }
103-
#[test] fn fat_uninit() { if !cfg!(target_os = "linux") { unsafe { fat::test::uninit_alloc_unsound(NewDeleteArray) } } }
103+
#[test] fn fat_uninit() { if !allocator::cpp::OPERATOR_NEW_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(NewDeleteArray) } } }
104104
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(NewDeleteArray) }
105105
#[test] fn fat_zst_support() { fat::test::zst_supported_conservative(NewDeleteArray) }

src/allocator/cpp/new_delete_array_aligned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ unsafe impl fat::Realloc for NewDeleteArrayAligned {}
8181

8282
#[test] fn fat_alignment() { fat::test::alignment(NewDeleteArrayAligned) }
8383
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(NewDeleteArrayAligned) }
84-
#[test] fn fat_uninit() { if !cfg!(target_os = "linux") { unsafe { fat::test::uninit_alloc_unsound(NewDeleteArrayAligned) } } }
84+
#[test] fn fat_uninit() { if !allocator::cpp::OPERATOR_NEW_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(NewDeleteArrayAligned) } } }
8585
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(NewDeleteArrayAligned) }
8686
#[test] fn fat_zst_support() { fat::test::zst_supported_conservative(NewDeleteArrayAligned) }

src/allocator/cpp/std_allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ unsafe impl fat::Realloc for StdAllocator<c_char> {}
106106

107107
#[test] fn fat_alignment() { fat::test::alignment(StdAllocator::<c_char>::new()) }
108108
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(StdAllocator::<c_char>::new()) }
109-
#[test] fn fat_uninit() { if !cfg!(target_os = "linux") { unsafe { fat::test::uninit_alloc_unsound(StdAllocator::<c_char>::new()) } } }
109+
#[test] fn fat_uninit() { if !allocator::cpp::OPERATOR_NEW_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(StdAllocator::<c_char>::new()) } } }
110110
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(StdAllocator::<c_char>::new()) }
111111
#[test] fn fat_zst_support() { fat::test::zst_supported_conservative(StdAllocator::<c_char>::new()) }

0 commit comments

Comments
 (0)