Skip to content

Commit 2878c05

Browse files
committed
Test more in miri, but don't print to the console
1 parent 1bf1b9a commit 2878c05

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/test.rs

+21-9
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,8 @@ fn allocate_many_size_aligns() {
193193
#[cfg(miri)]
194194
const ALIGN: Range<usize> = 1..4;
195195

196-
#[cfg(not(miri))]
197196
const STRATS: Range<usize> = 0..4;
198197

199-
#[cfg(miri)]
200-
const STRATS: Range<usize> = 0..2;
201-
202198
let mut heap = new_heap();
203199
assert_eq!(heap.size(), 1000);
204200

@@ -217,36 +213,45 @@ fn allocate_many_size_aligns() {
217213
layout: Layout,
218214
}
219215

216+
// NOTE: Printing to the console SIGNIFICANTLY slows down miri.
217+
220218
for strat in STRATS {
221219
for align in ALIGN {
222220
for size in SIZE {
223-
println!("=========================================================");
224-
println!("Align: {}", 1 << align);
225-
println!("Size: {}", size);
226-
println!("Free Pattern: {}/0..4", strat);
227-
println!();
221+
#[cfg(not(miri))]
222+
{
223+
println!("=========================================================");
224+
println!("Align: {}", 1 << align);
225+
println!("Size: {}", size);
226+
println!("Free Pattern: {}/0..4", strat);
227+
println!();
228+
}
228229
let mut allocs = vec![];
229230

230231
let layout = Layout::from_size_align(size, 1 << align).unwrap();
231232
while let Ok(alloc) = heap.allocate_first_fit(layout) {
233+
#[cfg(not(miri))]
232234
heap.holes.debug();
233235
allocs.push(Alloc { alloc, layout });
234236
}
235237

238+
#[cfg(not(miri))]
236239
println!("Allocs: {} - {} bytes", allocs.len(), allocs.len() * size);
237240

238241
match strat {
239242
0 => {
240243
// Forward
241244
allocs.drain(..).for_each(|a| unsafe {
242245
heap.deallocate(a.alloc, a.layout);
246+
#[cfg(not(miri))]
243247
heap.holes.debug();
244248
});
245249
}
246250
1 => {
247251
// Backwards
248252
allocs.drain(..).rev().for_each(|a| unsafe {
249253
heap.deallocate(a.alloc, a.layout);
254+
#[cfg(not(miri))]
250255
heap.holes.debug();
251256
});
252257
}
@@ -263,10 +268,12 @@ fn allocate_many_size_aligns() {
263268
}
264269
a.drain(..).for_each(|a| unsafe {
265270
heap.deallocate(a.alloc, a.layout);
271+
#[cfg(not(miri))]
266272
heap.holes.debug();
267273
});
268274
b.drain(..).for_each(|a| unsafe {
269275
heap.deallocate(a.alloc, a.layout);
276+
#[cfg(not(miri))]
270277
heap.holes.debug();
271278
});
272279
}
@@ -283,22 +290,27 @@ fn allocate_many_size_aligns() {
283290
}
284291
a.drain(..).for_each(|a| unsafe {
285292
heap.deallocate(a.alloc, a.layout);
293+
#[cfg(not(miri))]
286294
heap.holes.debug();
287295
});
288296
b.drain(..).for_each(|a| unsafe {
289297
heap.deallocate(a.alloc, a.layout);
298+
#[cfg(not(miri))]
290299
heap.holes.debug();
291300
});
292301
}
293302
_ => panic!(),
294303
}
295304

305+
#[cfg(not(miri))]
296306
println!("MAX CHECK");
297307

298308
let full = heap.allocate_first_fit(max_alloc).unwrap();
299309
unsafe {
300310
heap.deallocate(full, max_alloc);
301311
}
312+
313+
#[cfg(not(miri))]
302314
println!();
303315
}
304316
}

0 commit comments

Comments
 (0)