-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
various testing improvements #9
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#![feature(custom_attribute)] | ||
#![allow(dead_code, unused_attributes)] | ||
|
||
// error-pattern:can't handle intrinsic: discriminant_value | ||
|
||
#[miri_run] | ||
fn main() { | ||
assert_eq!(None::<i32>, None); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#![feature(custom_attribute)] | ||
#![allow(dead_code, unused_attributes)] | ||
|
||
// error-pattern:can't handle intrinsic: size_of_val | ||
|
||
#[miri_run] | ||
fn memcmp() { | ||
assert_eq!("", ""); | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![feature(custom_attribute)] | ||
#![allow(dead_code, unused_attributes)] | ||
|
||
#[miri_run] | ||
fn option_box_deref() -> i32 { | ||
let val = Some(Box::new(42)); | ||
unsafe { | ||
let ptr: *const i32 = std::mem::transmute(val); //~ ERROR: pointer offset outside bounds of allocation | ||
*ptr | ||
} | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#![feature(custom_attribute)] | ||
#![allow(dead_code, unused_attributes)] | ||
|
||
// error-pattern:assertion failed | ||
|
||
#[miri_run] | ||
fn slice() -> u8 { | ||
let arr: &[_] = &[101, 102, 103, 104, 105, 106]; | ||
arr[5] | ||
} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// error-pattern:no mir for DefId | ||
|
||
use std::env; | ||
use std::process::{Command, Output}; | ||
|
||
fn run_miri(file: &str, sysroot: &str) -> Output { | ||
let path = env::current_dir().unwrap(); | ||
let libpath = path.join("target").join("debug"); | ||
let libpath = libpath.to_str().unwrap(); | ||
let libpath2 = path.join("target").join("debug").join("deps"); | ||
let libpath2 = libpath2.to_str().unwrap(); | ||
Command::new("cargo") | ||
.args(&[ | ||
"run", "--", | ||
"--sysroot", sysroot, | ||
"-L", libpath, | ||
"-L", libpath2, | ||
file | ||
]) | ||
.output() | ||
.unwrap_or_else(|e| panic!("failed to execute process: {}", e)) | ||
} | ||
|
||
fn main() { | ||
let sysroot = env::var("RUST_SYSROOT").expect("env variable `RUST_SYSROOT` not set"); | ||
let test_run = run_miri("src/bin/miri.rs", &sysroot); | ||
|
||
if test_run.status.code().unwrap_or(-1) != 0 { | ||
println!("{}", String::from_utf8(test_run.stdout).unwrap()); | ||
panic!("{}", String::from_utf8(test_run.stderr).unwrap()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,7 @@ fn unsafe_match() -> bool { | |
} | ||
} | ||
|
||
fn main() {} | ||
#[miri_run] | ||
fn main() { | ||
assert!(unsafe_match()); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,6 @@ fn specialization() -> (bool, bool) { | |
(i32::is_unit(), <()>::is_unit()) | ||
} | ||
|
||
fn main() {} | ||
fn main() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope, it doesn't work, miri can't compare tuples There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not? It's just a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it errors here: https://github.com/tsion/miri/blob/master/src/primval.rs#L91 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haha, |
||
assert_eq!(specialization(), (false, true)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's the
std::env::args()
that are blocking thisThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hilarious test. :)
But yeah, it would need crate metadata to contain MIR for every function. And later it would fall down on some FFI call, but it would be fun to see how far it can go.