Skip to content

Commit 8466f78

Browse files
committed
ignore overaligned tests on Windows (because, of course, Windows' API is broken here)
1 parent 2d32385 commit 8466f78

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

tests/run-pass/heap.rs

-26
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
#![feature(box_syntax)]
2-
#![feature(allocator_api)]
3-
4-
use std::alloc::{Global, Alloc, Layout, System};
52

63
fn make_box() -> Box<(i16, i16)> {
74
Box::new((1, 2))
@@ -30,31 +27,8 @@ fn allocate_reallocate() {
3027
assert_eq!(s.capacity(), 9);
3128
}
3229

33-
fn check_overalign_requests<T: Alloc>(mut allocator: T) {
34-
let size = 8;
35-
let align = 16; // greater than size
36-
let iterations = 1; // Miri is deterministic, no need to try many times
37-
unsafe {
38-
let pointers: Vec<_> = (0..iterations).map(|_| {
39-
allocator.alloc(Layout::from_size_align(size, align).unwrap()).unwrap()
40-
}).collect();
41-
for &ptr in &pointers {
42-
assert_eq!((ptr.as_ptr() as usize) % align, 0,
43-
"Got a pointer less aligned than requested")
44-
}
45-
46-
// Clean up
47-
for &ptr in &pointers {
48-
allocator.dealloc(ptr, Layout::from_size_align(size, align).unwrap())
49-
}
50-
}
51-
}
52-
5330
fn main() {
5431
assert_eq!(*make_box(), (1, 2));
5532
assert_eq!(*make_box_syntax(), (1, 2));
5633
allocate_reallocate();
57-
58-
check_overalign_requests(System);
59-
check_overalign_requests(Global);
6034
}

tests/run-pass/heap_system.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//ignore-windows: Inspects allocation base address on Windows
2+
#![feature(allocator_api)]
3+
4+
use std::alloc::{Global, Alloc, Layout, System};
5+
6+
fn check_overalign_requests<T: Alloc>(mut allocator: T) {
7+
let size = 8;
8+
let align = 16; // greater than size
9+
let iterations = 1; // Miri is deterministic, no need to try many times
10+
unsafe {
11+
let pointers: Vec<_> = (0..iterations).map(|_| {
12+
allocator.alloc(Layout::from_size_align(size, align).unwrap()).unwrap()
13+
}).collect();
14+
for &ptr in &pointers {
15+
assert_eq!((ptr.as_ptr() as usize) % align, 0,
16+
"Got a pointer less aligned than requested")
17+
}
18+
19+
// Clean up
20+
for &ptr in &pointers {
21+
allocator.dealloc(ptr, Layout::from_size_align(size, align).unwrap())
22+
}
23+
}
24+
}
25+
26+
fn main() {
27+
check_overalign_requests(System);
28+
check_overalign_requests(Global);
29+
}

0 commit comments

Comments
 (0)