Skip to content

Commit

Permalink
Auto merge of #809 - RalfJung:intptrcast, r=<try>
Browse files Browse the repository at this point in the history
use intptrcast for heap_allocator test; then it should work on Windows
  • Loading branch information
bors committed Jun 30, 2019
2 parents 72b2e10 + 20753d9 commit 2d5620e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ build_script:

test_script:
# Test miri
- cargo test --release --all-features
- cargo test --release --all-features heap
- false
# Test cargo integration
- cd test-cargo-miri
- '"C:\msys64\mingw64\bin\python3.exe" run-test.py'
Expand Down
10 changes: 6 additions & 4 deletions tests/run-pass/heap_allocator.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// compile-flags: -Zmiri-seed=
#![feature(allocator_api)]

use std::ptr::NonNull;
Expand Down Expand Up @@ -32,14 +33,16 @@ fn check_overalign_requests<T: Alloc>(mut allocator: T) {
let size = 8;
// Greater than `size`.
let align = 16;
// Miri is deterministic; no need to try many times.
let iterations = 1;

let iterations = 5;
unsafe {
let pointers: Vec<_> = (0..iterations).map(|_| {
allocator.alloc(Layout::from_size_align(size, align).unwrap()).unwrap()
}).collect();
for &ptr in &pointers {
assert_eq!((ptr.as_ptr() as usize) % align, 0,
let ptr = ptr.as_ptr();
eprintln!("{:?}, {}", ptr, (ptr as usize) % 256);
assert_eq!((ptr as usize) % align, 0,
"Got a pointer less aligned than requested")
}

Expand Down Expand Up @@ -75,7 +78,6 @@ fn box_to_global() {
fn main() {
check_alloc(System);
check_alloc(Global);
#[cfg(not(target_os = "windows"))] // TODO: Inspects allocation base address on Windows; needs intptrcast model
check_overalign_requests(System);
check_overalign_requests(Global);
global_to_box();
Expand Down

0 comments on commit 2d5620e

Please sign in to comment.