Skip to content

Commit

Permalink
Merge pull request #395 from RalfJung/tests
Browse files Browse the repository at this point in the history
Test suite work
  • Loading branch information
oli-obk authored Jul 12, 2018
2 parents 54da84f + 9491061 commit f8fabe4
Show file tree
Hide file tree
Showing 20 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ RUSTFLAGS='-Zalways-encode-mir' xargo build
Now you can run miri against the libstd compiled by xargo:

```sh
MIRI_SYSROOT=~/.xargo/HOST cargo run --bin miri tests/run-pass-fullmir/vecs.rs
MIRI_SYSROOT=~/.xargo/HOST cargo run --bin miri tests/run-pass-fullmir/hashmap.rs
```

Notice that you will have to re-run the last step of the preparations above when
Expand Down
2 changes: 1 addition & 1 deletion tests/compile-fail/deallocate-bad-alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::alloc::*;

fn main() {
unsafe {
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
Global.dealloc(x, Layout::from_size_align_unchecked(1, 2));
}
}
2 changes: 1 addition & 1 deletion tests/compile-fail/deallocate-bad-size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::alloc::*;

fn main() {
unsafe {
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
Global.dealloc(x, Layout::from_size_align_unchecked(2, 1));
}
}
2 changes: 1 addition & 1 deletion tests/compile-fail/deallocate-twice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::alloc::*;

fn main() {
unsafe {
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
Global.dealloc(x, Layout::from_size_align_unchecked(1, 1));
Global.dealloc(x, Layout::from_size_align_unchecked(1, 1));
}
Expand Down
2 changes: 2 additions & 0 deletions tests/compile-fail/match_char.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore-test FIXME: we are not checking these things on match any more?

fn main() {
assert!(std::char::from_u32(-1_i32 as u32).is_none());
match unsafe { std::mem::transmute::<i32, char>(-1) } { //~ ERROR constant evaluation error [E0080]
Expand Down
1 change: 1 addition & 0 deletions tests/compile-fail/memleak.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore-test FIXME: leak detection is disabled
//error-pattern: the evaluated program leaked memory

fn main() {
Expand Down
1 change: 1 addition & 0 deletions tests/compile-fail/memleak_rc.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore-test FIXME: leak detection is disabled
//error-pattern: the evaluated program leaked memory

use std::rc::Rc;
Expand Down
2 changes: 1 addition & 1 deletion tests/compile-fail/overflowing-rsh-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
fn main() {
// Make sure we catch overflows that would be hidden by first casting the RHS to u32
let _n = 1i64 >> (u32::max_value() as i64 + 1); //~ ERROR constant evaluation error [E0080]
//~^ NOTE suiriuruihrihue
//~^ NOTE attempt to shift right with overflow
}
1 change: 1 addition & 0 deletions tests/compile-fail/panic.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//ignore-windows
// FIXME: Something in panic handling fails validation with full-MIR
// compile-flags: -Zmir-emit-validate=0
//error-pattern: the evaluated program panicked
Expand Down
4 changes: 2 additions & 2 deletions tests/compile-fail/reallocate-bad-size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::alloc::*;

fn main() {
unsafe {
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
let _y = Global.realloc(x, Layout::from_size_align_unchecked(2, 1), 1);
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
let _y = Global.realloc(x, Layout::from_size_align_unchecked(2, 1), 1).unwrap();
}
}
6 changes: 3 additions & 3 deletions tests/compile-fail/reallocate-change-alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use std::alloc::*;

fn main() {
unsafe {
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
let _y = Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
let _z = *(x as *mut u8); //~ ERROR constant evaluation error [E0080]
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
let _y = Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1).unwrap();
let _z = *(x.as_ptr() as *mut u8); //~ ERROR constant evaluation error [E0080]
//~^ NOTE dangling pointer was dereferenced
}
}
4 changes: 2 additions & 2 deletions tests/compile-fail/reallocate-dangling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use std::alloc::*;

fn main() {
unsafe {
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1));
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
Global.dealloc(x, Layout::from_size_align_unchecked(1, 1));
Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1).unwrap();
}
}
1 change: 1 addition & 0 deletions tests/compile-fail/static_memory_modification.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore-test FIXME: we are not making these statics read-only any more?
static X: usize = 5;

#[allow(mutable_transmutes)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
fn main() {
let v: Vec<u8> = Vec::with_capacity(10);
let undef = unsafe { *v.get_unchecked(5) };
let x = undef + 1; //~ ERROR: attempted to read undefined bytes
let x = undef + 1; //~ ERROR: error
//~^ NOTE attempted to read undefined bytes
panic!("this should never print: {}", x);
}
8 changes: 4 additions & 4 deletions tests/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ fn run_pass_miri_noopt() {
}

#[test]
#[ignore] // FIXME: Disabled for now, as the optimizer is pretty broken and crashes...
#[ignore]
// FIXME: Disabled for now, as the optimizer is pretty broken and crashes...
// See https://github.com/rust-lang/rust/issues/50411
fn run_pass_miri_opt() {
run_pass_miri(true);
}
Expand All @@ -204,13 +206,11 @@ fn run_pass_rustc() {
}

#[test]
#[should_panic] // TODO: update test errors
fn compile_fail_miri() {
let sysroot = get_sysroot();
let host = get_host();

// FIXME: run tests for other targets, too
compile_fail(&sysroot, "tests/compile-fail", &host, &host, true);

compile_fail(&sysroot, "tests/compile-fail-fullmir", &host, &host, true);
//compile_fail(&sysroot, "tests/compile-fail-fullmir", &host, &host, true);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// FIXME: We handle uninitialzied storage here, which currently makes validation fail.
// FIXME: We handle uninitialized storage here, which currently makes validation fail.
// compile-flags: -Zmir-emit-validate=0

//ignore-msvc
Expand Down
File renamed without changes.

0 comments on commit f8fabe4

Please sign in to comment.