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 + 2a92157 commit 899e5bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ install:
build_script:
- set RUST_TEST_NOCAPTURE=1
- set RUST_BACKTRACE=1
- set MIRI_BACKTRACE=1
- set RUSTFLAGS=-C debug-assertions
# Build and install miri
- cargo build --release --all-features --all-targets
Expand All @@ -41,7 +42,7 @@ build_script:

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

use std::ptr::NonNull;
Expand Down Expand Up @@ -32,14 +33,15 @@ 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() as usize;
assert_eq!(ptr % align, 0,
"Got a pointer less aligned than requested")
}

Expand Down Expand Up @@ -75,7 +77,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 899e5bf

Please sign in to comment.