1
Fork 0

test the memory limit

This commit is contained in:
Oliver Schneider 2016-07-05 13:04:53 +02:00
parent 1444cabc08
commit 3e5d86bb08
No known key found for this signature in database
GPG key ID: 56D6EEA0FC67AC46
2 changed files with 50 additions and 0 deletions

11
tests/compile-fail/oom.rs Normal file
View file

@ -0,0 +1,11 @@
#![feature(custom_attribute)]
#![miri(memory_size="0")]
fn bar() {
let x = 5;
assert_eq!(x, 6);
}
fn main() { //~ ERROR tried to allocate 4 more bytes, but only 0 bytes are free of the 0 byte memory
bar();
}

View file

@ -0,0 +1,39 @@
#![feature(custom_attribute)]
#![miri(memory_size="1000")]
fn bar(i: i32) {
if i < 1000 {
bar(i + 1) //~ ERROR tried to allocate 4 more bytes, but only 1 bytes are free of the 1000 byte memory
//~^NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
//~|NOTE inside call to bar
}
}
fn main() { //~NOTE inside call to main
bar(1);
//~^NOTE inside call to bar
}