Skip to content

Commit 1c7a7c8

Browse files
committed
test coverage: start testing reallocs, check in tests for passing allocators
relates to #32
1 parent c466821 commit 1c7a7c8

File tree

15 files changed

+343
-5
lines changed

15 files changed

+343
-5
lines changed

src/allocator/alloc/global.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,5 +205,7 @@ unsafe impl core::alloc::GlobalAlloc for Global {
205205
#[test] fn fat_alignment() { fat::test::alignment(Global) }
206206
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(Global) }
207207
#[test] fn fat_uninit() { if !GLOBAL_ALLOC_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(Global) } } }
208+
#[test] fn fat_uninit_realloc() { fat::test::uninit_realloc(Global) }
208209
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(Global) }
210+
#[test] fn fat_zeroed_realloc() { fat::test::zeroed_realloc(Global) }
209211
#[test] fn fat_zst_support() { fat::test::zst_supported_accurate(Global) }

src/allocator/cpp/new_delete.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,15 @@ unsafe impl fat::Realloc for NewDelete {}
100100
#[test] fn thin_edge_case_sizes() { thin::test::edge_case_sizes(NewDelete) }
101101
#[test] fn thin_nullable() { thin::test::nullable(NewDelete) }
102102
#[test] fn thin_uninit() { if !OPERATOR_NEW_ZERO_INITS { unsafe { thin::test::uninit_alloc_unsound(NewDelete) } } }
103+
//test] fn thin_uninit_realloc() { thin::test::uninit_realloc(NewDelete) } // does not implement thin::Realloc
103104
#[test] fn thin_zeroed() { thin::test::zeroed_alloc(NewDelete) }
105+
//test] fn thin_zeroed_realloc() { thin::test::zeroed_realloc(NewDelete) } // does not implement thin::Realloc
104106
#[test] fn thin_zst_support() { thin::test::zst_supported_conservative(NewDelete) }
105107

106108
#[test] fn fat_alignment() { fat::test::alignment(NewDelete) }
107109
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(NewDelete) }
108110
#[test] fn fat_uninit() { if !OPERATOR_NEW_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(NewDelete) } } }
111+
#[test] fn fat_uninit_realloc() { fat::test::uninit_realloc(NewDelete) }
109112
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(NewDelete) }
113+
#[test] fn fat_zeroed_realloc() { fat::test::zeroed_realloc(NewDelete) }
110114
#[test] fn fat_zst_support() { fat::test::zst_supported_conservative(NewDelete) }

src/allocator/cpp/new_delete_aligned.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,7 @@ unsafe impl fat::Realloc for NewDeleteAligned {}
8282
#[test] fn fat_alignment() { fat::test::alignment(NewDeleteAligned) }
8383
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(NewDeleteAligned) }
8484
#[test] fn fat_uninit() { if !allocator::cpp::OPERATOR_NEW_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(NewDeleteAligned) } } }
85+
#[test] fn fat_uninit_realloc() { fat::test::uninit_realloc(NewDeleteAligned) }
8586
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(NewDeleteAligned) }
87+
#[test] fn fat_zeroed_realloc() { fat::test::zeroed_realloc(NewDeleteAligned) }
8688
#[test] fn fat_zst_support() { fat::test::zst_supported_conservative(NewDeleteAligned) }

src/allocator/cpp/new_delete_array.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,15 @@ unsafe impl fat::Realloc for NewDeleteArray {}
9595
#[test] fn thin_edge_case_sizes() { thin::test::edge_case_sizes(NewDeleteArray) }
9696
#[test] fn thin_nullable() { thin::test::nullable(NewDeleteArray) }
9797
#[test] fn thin_uninit() { if !allocator::cpp::OPERATOR_NEW_ZERO_INITS { unsafe { thin::test::uninit_alloc_unsound(NewDeleteArray) } } }
98+
//test] fn thin_uninit_realloc() { thin::test::uninit_realloc(NewDeleteArray) } // does not implement thin::Realloc
9899
#[test] fn thin_zeroed() { thin::test::zeroed_alloc(NewDeleteArray) }
100+
//test] fn thin_zeroed_realloc() { thin::test::zeroed_realloc(NewDeleteArray) } // does not implement thin::Realloc
99101
#[test] fn thin_zst_support() { thin::test::zst_supported_conservative(NewDeleteArray) }
100102

101103
#[test] fn fat_alignment() { fat::test::alignment(NewDeleteArray) }
102104
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(NewDeleteArray) }
103105
#[test] fn fat_uninit() { if !allocator::cpp::OPERATOR_NEW_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(NewDeleteArray) } } }
106+
#[test] fn fat_uninit_realloc() { fat::test::uninit_realloc(NewDeleteArray) }
104107
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(NewDeleteArray) }
108+
#[test] fn fat_zeroed_realloc() { fat::test::zeroed_realloc(NewDeleteArray) }
105109
#[test] fn fat_zst_support() { fat::test::zst_supported_conservative(NewDeleteArray) }

src/allocator/cpp/new_delete_array_aligned.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,7 @@ unsafe impl fat::Realloc for NewDeleteArrayAligned {}
8282
#[test] fn fat_alignment() { fat::test::alignment(NewDeleteArrayAligned) }
8383
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(NewDeleteArrayAligned) }
8484
#[test] fn fat_uninit() { if !allocator::cpp::OPERATOR_NEW_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(NewDeleteArrayAligned) } } }
85+
#[test] fn fat_uninit_realloc() { fat::test::uninit_realloc(NewDeleteArrayAligned) }
8586
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(NewDeleteArrayAligned) }
87+
#[test] fn fat_zeroed_realloc() { fat::test::zeroed_realloc(NewDeleteArrayAligned) }
8688
#[test] fn fat_zst_support() { fat::test::zst_supported_conservative(NewDeleteArrayAligned) }

src/allocator/cpp/std_allocator.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,7 @@ unsafe impl fat::Realloc for StdAllocator<c_char> {}
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()) }
109109
#[test] fn fat_uninit() { if !allocator::cpp::OPERATOR_NEW_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(StdAllocator::<c_char>::new()) } } }
110+
#[test] fn fat_uninit_realloc() { fat::test::uninit_realloc(StdAllocator::<c_char>::new()) }
110111
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(StdAllocator::<c_char>::new()) }
112+
#[test] fn fat_zeroed_realloc() { fat::test::zeroed_realloc(StdAllocator::<c_char>::new()) }
111113
#[test] fn fat_zst_support() { fat::test::zst_supported_conservative(StdAllocator::<c_char>::new()) }

src/allocator/debug/null.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,7 @@ unsafe impl fat::Realloc for Null {
9090
#[test] fn thin_nullable() { thin::test::nullable(Null) }
9191
#[test] fn thin_size() { thin::test::size_exact_alloc(Null) }
9292
#[test] fn thin_uninit() { unsafe { thin::test::uninit_alloc_unsound(Null) } }
93+
#[test] fn thin_uninit_realloc() { thin::test::uninit_realloc(Null) }
9394
#[test] fn thin_zeroed() { thin::test::zeroed_alloc(Null) }
95+
#[test] fn thin_zeroed_realloc() { thin::test::zeroed_realloc(Null) }
9496
//#[test] fn thin_zst_support() { thin::test::zst_supported_conservative(Null) } // XXX: Null intentionally claims support for anything but won't ever allocate

src/allocator/simple/bump.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,7 @@ unsafe impl<'a> fat::Realloc for Bump<'a> {
172172
#[test] fn fat_alignment() { fat::test::alignment(&Bump::from_array(&mut MaybeUninit::new([(); 131072].map(|_| MaybeUninit::<u8>::new(0xFF))))) }
173173
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(&Bump::from_array(&mut MaybeUninit::new([(); 131072].map(|_| MaybeUninit::<u8>::new(0xFF))))) }
174174
#[test] fn fat_uninit() { unsafe { fat::test::uninit_alloc_unsound(&Bump::from_array(&mut MaybeUninit::new([(); 131072].map(|_| MaybeUninit::<u8>::new(0xFF))))) } }
175+
#[test] fn fat_uninit_realloc() { fat::test::uninit_realloc(&Bump::from_array(&mut MaybeUninit::new([(); 131072].map(|_| MaybeUninit::<u8>::new(0xFF))))) }
175176
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(&Bump::from_array(&mut MaybeUninit::new([(); 131072].map(|_| MaybeUninit::<u8>::new(0xFF))))) }
177+
#[test] fn fat_zeroed_realloc() { fat::test::zeroed_realloc(&Bump::from_array(&mut MaybeUninit::new([(); 131072].map(|_| MaybeUninit::<u8>::new(0xFF))))) }
176178
#[test] fn fat_zst_support() { fat::test::zst_supported_accurate(&Bump::from_array(&mut MaybeUninit::new([(); 131072].map(|_| MaybeUninit::<u8>::new(0xFF))))) }

src/allocator/simple/fixed_pool.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,15 @@ type Element<const A : usize, const B : usize> = UnsafeCell<MaybeUninit<AlignN<A
219219
#[test] fn thin_nullable() { thin::test::nullable(&FixedPoolLinearProbe::<4, 4, 1024>::new()) }
220220
//#[test] fn thin_size() { thin::test::size_over_alloc(&FixedPoolLinearProbe::<4, 4, 1024>::new()) } // NYI
221221
#[test] fn thin_uninit() { unsafe { thin::test::uninit_alloc_unsound(&FixedPoolLinearProbe::<4, 4, 128>::new()) } }
222+
#[test] fn thin_uninit_realloc() { thin::test::uninit_realloc(&FixedPoolLinearProbe::<4, 4, 128>::new()) }
222223
#[test] fn thin_zeroed() { thin::test::zeroed_alloc(&FixedPoolLinearProbe::<4, 4, 128>::new()) }
224+
#[test] fn thin_zeroed_realloc() { thin::test::zeroed_realloc(&FixedPoolLinearProbe::<4, 4, 128>::new()) }
223225
#[test] fn thin_zst_support() { thin::test::zst_supported_accurate(&FixedPoolLinearProbe::<4, 4, 1024>::new()) }
224226

225227
#[test] fn fat_alignment() { fat::test::alignment(&FixedPoolLinearProbe::<4, 4, 1024>::new()) }
226228
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(&FixedPoolLinearProbe::<4, 4, 1024>::new()) }
227229
#[test] fn fat_uninit() { unsafe { fat::test::uninit_alloc_unsound(&FixedPoolLinearProbe::<4, 4, 128>::new()) } }
230+
#[test] fn fat_uninit_realloc() { fat::test::uninit_realloc(&FixedPoolLinearProbe::<4, 4, 128>::new()) }
228231
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(&FixedPoolLinearProbe::<4, 4, 128>::new()) }
232+
#[test] fn fat_zeroed_realloc() { fat::test::zeroed_realloc(&FixedPoolLinearProbe::<4, 4, 128>::new()) }
229233
#[test] fn fat_zst_support() { fat::test::zst_supported_accurate(&FixedPoolLinearProbe::<4, 4, 1024>::new()) }

src/allocator/win32/cryptmem.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,17 @@ unsafe impl thin::Free for CryptMem {
127127
#[test] fn thin_alignment() { thin::test::alignment(CryptMem) }
128128
#[test] fn thin_edge_case_sizes() { thin::test::edge_case_sizes(CryptMem) }
129129
#[test] fn thin_nullable() { thin::test::nullable(CryptMem) }
130-
//#[test] fn thin_size() { ...no CryptMemSizeOf... }
131-
//#[test] fn thin_uninit() { unsafe { thin::test::uninit_alloc_unsound(CryptMem) } } // Interestingly, CryptMem appears to zero it's memory. This isn't documented, so I choose not to rely on it, but it's interesting...
130+
//test] fn thin_size() { ...no CryptMemSizeOf... }
131+
//test] fn thin_uninit() { unsafe { thin::test::uninit_alloc_unsound(CryptMem) } } // Interestingly, CryptMem appears to zero it's memory. This isn't documented, so I choose not to rely on it, but it's interesting...
132+
#[test] fn thin_uninit_realloc() { thin::test::uninit_realloc(CryptMem) }
132133
#[test] fn thin_zeroed() { thin::test::zeroed_alloc(CryptMem) }
134+
#[test] fn thin_zeroed_realloc() { thin::test::zeroed_realloc(CryptMem) }
133135
#[test] fn thin_zst_support() { thin::test::zst_supported_accurate(CryptMem) }
134136

135137
#[test] fn fat_alignment() { fat::test::alignment(CryptMem) }
136138
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(CryptMem) }
137-
//#[test] fn fat_uninit() { unsafe { fat::test::uninit_alloc_unsound(CryptMem) } } // CryptMem is always zeroed
139+
//test] fn fat_uninit() { unsafe { fat::test::uninit_alloc_unsound(CryptMem) } } // CryptMem is always zeroed
140+
#[test] fn fat_uninit_realloc() { fat::test::uninit_realloc(CryptMem) }
138141
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(CryptMem) }
142+
#[test] fn fat_zeroed_realloc() { fat::test::zeroed_realloc(CryptMem) }
139143
#[test] fn fat_zst_support() { fat::test::zst_supported_accurate(CryptMem) }

0 commit comments

Comments
 (0)