update tests for new allocator API

This commit is contained in:
Ralf Jung 2017-07-10 15:58:47 -07:00
parent d2cf3d76b9
commit ea730ab20f
6 changed files with 38 additions and 21 deletions

View file

@ -1,13 +1,16 @@
#![feature(alloc, heap_api)]
#![feature(alloc, allocator_api)]
extern crate alloc;
use alloc::heap::Heap;
use alloc::allocator::*;
// error-pattern: tried to deallocate or reallocate using incorrect alignment or size
use alloc::heap::*;
fn main() {
unsafe {
let x = allocate(1, 1);
deallocate(x, 1, 2);
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
Heap.dealloc(x, Layout::from_size_align_unchecked(1, 2));
}
}

View file

@ -1,13 +1,16 @@
#![feature(alloc, heap_api)]
#![feature(alloc, allocator_api)]
extern crate alloc;
use alloc::heap::Heap;
use alloc::allocator::*;
// error-pattern: tried to deallocate or reallocate using incorrect alignment or size
use alloc::heap::*;
fn main() {
unsafe {
let x = allocate(1, 1);
deallocate(x, 1, 2);
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
Heap.dealloc(x, Layout::from_size_align_unchecked(2, 1));
}
}

View file

@ -1,14 +1,17 @@
#![feature(alloc, heap_api)]
#![feature(alloc, allocator_api)]
extern crate alloc;
use alloc::heap::Heap;
use alloc::allocator::*;
// error-pattern: tried to deallocate with a pointer not to the beginning of an existing object
use alloc::heap::*;
fn main() {
unsafe {
let x = allocate(1, 1);
deallocate(x, 1, 1);
deallocate(x, 1, 1);
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
Heap.dealloc(x, Layout::from_size_align_unchecked(1, 1));
Heap.dealloc(x, Layout::from_size_align_unchecked(1, 1));
}
}

View file

@ -1,13 +1,16 @@
#![feature(alloc, heap_api)]
#![feature(alloc, allocator_api)]
extern crate alloc;
// error-pattern: tried to access memory with alignment 1, but alignment 2 is required
use alloc::heap::Heap;
use alloc::allocator::*;
// error-pattern: tried to deallocate or reallocate using incorrect alignment or size
use alloc::heap::*;
fn main() {
unsafe {
let x = allocate(1, 1);
let _y = reallocate(x, 1, 1, 2);
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 2)).unwrap();
let _y = Heap.realloc(x, Layout::from_size_align_unchecked(1, 1), Layout::from_size_align_unchecked(1, 2)).unwrap();
}
}

View file

@ -1,13 +1,16 @@
#![feature(alloc, heap_api)]
#![feature(alloc, allocator_api)]
extern crate alloc;
use alloc::heap::Heap;
use alloc::allocator::*;
// error-pattern: tried to deallocate or reallocate using incorrect alignment or size
use alloc::heap::*;
fn main() {
unsafe {
let x = allocate(1, 1);
let _y = reallocate(x, 2, 1, 1);
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
let _y = Heap.realloc(x, Layout::from_size_align_unchecked(2, 1), Layout::from_size_align_unchecked(1, 1)).unwrap();
}
}

View file

@ -1,12 +1,14 @@
#![feature(alloc, heap_api)]
#![feature(alloc, allocator_api)]
extern crate alloc;
use alloc::heap::*;
use alloc::heap::Heap;
use alloc::allocator::*;
fn main() {
unsafe {
let x = allocate(1, 1);
let _y = reallocate(x, 1, 1, 1);
let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
let _y = Heap.realloc(x, Layout::from_size_align_unchecked(1, 1), Layout::from_size_align_unchecked(1, 1)).unwrap();
let _z = *x; //~ ERROR: dangling pointer was dereferenced
}
}