From 851f2ab98e9ff67bdfb2bb20c9a639b35bc71799 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 26 Jul 2018 16:43:45 +0200 Subject: [PATCH 1/7] test `cargo miri` output --- .travis.yml | 8 ++++++-- cargo-miri-test/.gitignore | 1 + cargo-miri-test/src/main.rs | 2 ++ cargo-miri-test/stderr.ref | 1 + cargo-miri-test/stdout.ref | 1 + src/fn_call.rs | 2 +- 6 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 cargo-miri-test/.gitignore create mode 100644 cargo-miri-test/stderr.ref create mode 100644 cargo-miri-test/stdout.ref diff --git a/.travis.yml b/.travis.yml index 9aa632da05e0..b130c6dc5b2b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,13 @@ script: RUST_BACKTRACE=1 cargo test --release --all-features --all && cargo install --all-features --force - | - # Test cargo miri + # Test `cargo miri` cd cargo-miri-test && - cargo miri && + MIRI_SYSROOT=~/.xargo/HOST cargo miri -q -- -Zmiri-start-fn >stdout.real 2>stderr.real && + # Test `cargo miri` output. + diff stdout.ref stdout.real && + diff stderr.ref stderr.real && + # Test `cargo miri test` #cargo miri test && cd .. - | diff --git a/cargo-miri-test/.gitignore b/cargo-miri-test/.gitignore new file mode 100644 index 000000000000..56f307a7fb13 --- /dev/null +++ b/cargo-miri-test/.gitignore @@ -0,0 +1 @@ +*.real diff --git a/cargo-miri-test/src/main.rs b/cargo-miri-test/src/main.rs index 07b0e4cee4e5..6ad516710e1b 100644 --- a/cargo-miri-test/src/main.rs +++ b/cargo-miri-test/src/main.rs @@ -6,4 +6,6 @@ fn main() { let buf = &[1,2,3,4]; let n = ::read_u32(buf); assert_eq!(n, 0x01020304); + println!("{:#x}", n); + eprintln!("standard error"); } diff --git a/cargo-miri-test/stderr.ref b/cargo-miri-test/stderr.ref new file mode 100644 index 000000000000..aa7d1a2bdec7 --- /dev/null +++ b/cargo-miri-test/stderr.ref @@ -0,0 +1 @@ +standard error diff --git a/cargo-miri-test/stdout.ref b/cargo-miri-test/stdout.ref new file mode 100644 index 000000000000..53fefc734c85 --- /dev/null +++ b/cargo-miri-test/stdout.ref @@ -0,0 +1 @@ +0x1020304 diff --git a/src/fn_call.rs b/src/fn_call.rs index 31b3b4b18d17..a51ff73008ec 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -612,7 +612,7 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx> for EvalContext<'a, 'mir, ' // Stub out all the other pthread calls to just return 0 link_name if link_name.starts_with("pthread_") => { - info!("ignoring C ABI call: {}", link_name); + debug!("ignoring C ABI call: {}", link_name); self.write_null(dest, dest_ty)?; } From ee9879918541e55f246d1f969022303c33e7feb4 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 26 Jul 2018 16:49:10 +0200 Subject: [PATCH 2/7] we no longer need to mess with the environment in our test suite --- tests/compiletest.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/compiletest.rs b/tests/compiletest.rs index 38d806967281..82a2144a337d 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -8,7 +8,6 @@ use colored::*; use std::slice::SliceConcatExt; use std::path::{PathBuf, Path}; use std::io::Write; -use std::env; macro_rules! eprintln { ($($arg:tt)*) => { @@ -111,9 +110,6 @@ fn miri_pass(sysroot: &Path, path: &str, target: &str, host: &str, need_fullmir: // For now, only validate without optimizations. Inlining breaks validation. flags.push("-Zmir-emit-validate=1".to_owned()); } - // Control miri logging. This is okay despite concurrent test execution as all tests - // will set this env var to the same value. - env::set_var("MIRI_LOG", "warn"); config.target_rustcflags = Some(flags.join(" ")); compiletest::run_tests(&config); } From 5bd02b7c075802df68e215125e0b0cf7cce1aaa4 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 26 Jul 2018 17:08:29 +0200 Subject: [PATCH 3/7] also show the output (though we lost the interleaving) --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index b130c6dc5b2b..44a124efda3a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,7 @@ script: # Test `cargo miri` cd cargo-miri-test && MIRI_SYSROOT=~/.xargo/HOST cargo miri -q -- -Zmiri-start-fn >stdout.real 2>stderr.real && + cat stdout.real stderr.real && # Test `cargo miri` output. diff stdout.ref stdout.real && diff stderr.ref stderr.real && From f6d4814fb34e5ed3e35f0bd0e070d244fd48f485 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 26 Jul 2018 17:30:52 +0200 Subject: [PATCH 4/7] detect another printing function for nicer error --- src/fn_call.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fn_call.rs b/src/fn_call.rs index a51ff73008ec..9dfff9f55398 100644 --- a/src/fn_call.rs +++ b/src/fn_call.rs @@ -759,7 +759,8 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx> for EvalContext<'a, 'mir, ' match &path[..] { // A Rust function is missing, which means we are running with MIR missing for libstd (or other dependencies). // Still, we can make many things mostly work by "emulating" or ignoring some functions. - "std::io::_print" => { + "std::io::_print" | + "std::io::_eprint" => { warn!( "Ignoring output. To run programs that print, make sure you have a libstd with full MIR." ); From ae830f61153e079e0ed030351f22cd0fa14abf1a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 26 Jul 2018 17:41:45 +0200 Subject: [PATCH 5/7] dont test cargo miri output on mac. no idea what that system is doing. --- .travis.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 44a124efda3a..865da6f66499 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,11 +32,16 @@ script: - | # Test `cargo miri` cd cargo-miri-test && - MIRI_SYSROOT=~/.xargo/HOST cargo miri -q -- -Zmiri-start-fn >stdout.real 2>stderr.real && - cat stdout.real stderr.real && - # Test `cargo miri` output. - diff stdout.ref stdout.real && - diff stderr.ref stderr.real && + if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + MIRI_SYSROOT=~/.xargo/HOST cargo miri -q -- -Zmiri-start-fn + else + MIRI_SYSROOT=~/.xargo/HOST cargo miri -q -- -Zmiri-start-fn >stdout.real 2>stderr.real && + cat stdout.real stderr.real && + # Test `cargo miri` output. Not on mac because output redirecting doesn't + # work. There is no error. It just stops CI. + diff stdout.ref stdout.real && + diff stderr.ref stderr.real + fi && # Test `cargo miri test` #cargo miri test && cd .. From c490151b16a07ccd261af44b4ddf5832ceda8c5a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 26 Jul 2018 17:58:37 +0200 Subject: [PATCH 6/7] memrchr currently does not work --- cargo-miri-test/src/main.rs | 2 +- cargo-miri-test/stdout.ref | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cargo-miri-test/src/main.rs b/cargo-miri-test/src/main.rs index 6ad516710e1b..3fb265f6a7ba 100644 --- a/cargo-miri-test/src/main.rs +++ b/cargo-miri-test/src/main.rs @@ -6,6 +6,6 @@ fn main() { let buf = &[1,2,3,4]; let n = ::read_u32(buf); assert_eq!(n, 0x01020304); - println!("{:#x}", n); + //println!("{:#x}", n); FIXME enable once memrchr works in miri eprintln!("standard error"); } diff --git a/cargo-miri-test/stdout.ref b/cargo-miri-test/stdout.ref index 53fefc734c85..e69de29bb2d1 100644 --- a/cargo-miri-test/stdout.ref +++ b/cargo-miri-test/stdout.ref @@ -1 +0,0 @@ -0x1020304 From e2c1b7008642cfea12b347ed3dc4a7dd0e1f0ad0 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 26 Jul 2018 18:15:51 +0200 Subject: [PATCH 7/7] nicer diff formating --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 865da6f66499..d05661a48487 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,8 +39,8 @@ script: cat stdout.real stderr.real && # Test `cargo miri` output. Not on mac because output redirecting doesn't # work. There is no error. It just stops CI. - diff stdout.ref stdout.real && - diff stderr.ref stderr.real + diff -u stdout.ref stdout.real && + diff -u stderr.ref stderr.real fi && # Test `cargo miri test` #cargo miri test &&