Auto merge of #917 - RalfJung:isolation, r=oli-obk

change flag name: enable-communication -> disable-isolation

r? @oli-obk  -- I think this is a better name for the flag but it is still somewhat clumsy. Suggestions?
This commit is contained in:
bors 2019-08-27 10:02:07 +00:00
commit 2be0db4c0b
4 changed files with 23 additions and 5 deletions

View file

@ -157,9 +157,9 @@ Several `-Z` flags are relevant for Miri:
is enforced by default. This is mostly useful for debugging; it means Miri
will miss bugs in your program. However, this can also help to make Miri run
faster.
* `-Zmiri-enable-communication` enables communication between the host
environment and Miri, i.e., Miri uses the host's random number generator and
all the host environment variables are available during runtime.
* `-Zmiri-disable-isolation` disables host host isolation. As a consequence,
the program has access to host resources such as environment variables and
randomness (and, eventually, file systems and more).
* `-Zmir-opt-level` controls how many MIR optimizations are performed. Miri
overrides the default to be `0`; be advised that using any higher level can
make Miri miss bugs in your program because they got optimized away.

View file

@ -148,7 +148,7 @@ fn main() {
"-Zmiri-disable-validation" => {
validate = false;
},
"-Zmiri-enable-communication" => {
"-Zmiri-disable-isolation" => {
communicate = true;
},
"--" => {

View file

@ -1,5 +1,5 @@
// ignore-windows: TODO env var emulation stubbed out on Windows
// compile-flags: -Zmiri-enable-communication
// compile-flags: -Zmiri-disable-isolation
fn main() {
assert_eq!(std::env::var("MIRI_ENV_VAR_TEST"), Ok("0".to_owned()));

View file

@ -0,0 +1,18 @@
// Unfortunately, compiletest_rs does not support 'only-linux',
// so we need to ignore Windows and macOS instead.
// ignore-macos: Uses Linux-only APIs
// ignore-windows: Uses Linux-only APIs
// compile-flags: -Zmiri-disable-isolation
#![feature(rustc_private)]
extern crate libc;
fn main() {
let mut buf = [0u8; 5];
unsafe {
assert_eq!(libc::syscall(libc::SYS_getrandom, 0 as *mut libc::c_void, 0 as libc::size_t, 0 as libc::c_uint), 0);
assert_eq!(libc::syscall(libc::SYS_getrandom, buf.as_mut_ptr() as *mut libc::c_void, 5 as libc::size_t, 0 as libc::c_uint), 5);
assert_eq!(libc::getrandom(0 as *mut libc::c_void, 0 as libc::size_t, 0 as libc::c_uint), 0);
assert_eq!(libc::getrandom(buf.as_mut_ptr() as *mut libc::c_void, 5 as libc::size_t, 0 as libc::c_uint), 5);
}
}