diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2022-11-24 21:22:12 +0100 |
|---|---|---|
| committer | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2022-11-25 18:28:35 +0100 |
| commit | 2c456b5123d3546732683c4fe6dce5be822e15d1 (patch) | |
| tree | 034a9968aebfba070344fe99a249c45a2110541f /src | |
| parent | 8b0b2d136eb2db9ab0248e791e2db0228189dde2 (diff) | |
| download | rust-2c456b5123d3546732683c4fe6dce5be822e15d1.tar.gz rust-2c456b5123d3546732683c4fe6dce5be822e15d1.zip | |
Test a small cargo-miri smoke test even in `run_tests_minimal`
This makes sure that cargo-miri works on all targets.
Diffstat (limited to 'src')
| -rwxr-xr-x | src/tools/miri/ci.sh | 4 | ||||
| -rw-r--r-- | src/tools/miri/test-cargo-miri/Cargo.lock | 4 | ||||
| -rw-r--r-- | src/tools/miri/test-cargo-miri/Cargo.toml | 1 | ||||
| -rw-r--r-- | src/tools/miri/test-cargo-miri/no-std-smoke/Cargo.lock | 7 | ||||
| -rw-r--r-- | src/tools/miri/test-cargo-miri/no-std-smoke/Cargo.toml | 14 | ||||
| -rw-r--r-- | src/tools/miri/test-cargo-miri/no-std-smoke/src/main.rs | 34 |
6 files changed, 64 insertions, 0 deletions
diff --git a/src/tools/miri/ci.sh b/src/tools/miri/ci.sh index 72b7b791a47..bf9e986bdc7 100755 --- a/src/tools/miri/ci.sh +++ b/src/tools/miri/ci.sh @@ -73,6 +73,10 @@ function run_tests_minimal { fi ./miri test -- "$@" + + # Ensure that a small smoke test of cargo-miri works. + # Note: This doesn't work on windows because of TLS. + cargo miri run --manifest-path test-cargo-miri/no-std-smoke/Cargo.toml } # host diff --git a/src/tools/miri/test-cargo-miri/Cargo.lock b/src/tools/miri/test-cargo-miri/Cargo.lock index 2c53c482bf9..d037a37e0f6 100644 --- a/src/tools/miri/test-cargo-miri/Cargo.lock +++ b/src/tools/miri/test-cargo-miri/Cargo.lock @@ -82,6 +82,10 @@ name = "issue_rust_86261" version = "0.1.0" [[package]] +name = "no-std-smoke" +version = "0.1.0" + +[[package]] name = "proc-macro2" version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/src/tools/miri/test-cargo-miri/Cargo.toml b/src/tools/miri/test-cargo-miri/Cargo.toml index 5d9e5d143b3..37c996de662 100644 --- a/src/tools/miri/test-cargo-miri/Cargo.toml +++ b/src/tools/miri/test-cargo-miri/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = ["subcrate", "issue-1567", "exported-symbol-dep"] +exclude = ["no-std-smoke"] # it wants to be panic="abort" [package] name = "cargo-miri-test" diff --git a/src/tools/miri/test-cargo-miri/no-std-smoke/Cargo.lock b/src/tools/miri/test-cargo-miri/no-std-smoke/Cargo.lock new file mode 100644 index 00000000000..b92a05fccf8 --- /dev/null +++ b/src/tools/miri/test-cargo-miri/no-std-smoke/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "no-std-smoke" +version = "0.1.0" diff --git a/src/tools/miri/test-cargo-miri/no-std-smoke/Cargo.toml b/src/tools/miri/test-cargo-miri/no-std-smoke/Cargo.toml new file mode 100644 index 00000000000..3a056bedaa0 --- /dev/null +++ b/src/tools/miri/test-cargo-miri/no-std-smoke/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "no-std-smoke" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + +[profile.dev] +panic = 'abort' + +[profile.release] +panic = 'abort' diff --git a/src/tools/miri/test-cargo-miri/no-std-smoke/src/main.rs b/src/tools/miri/test-cargo-miri/no-std-smoke/src/main.rs new file mode 100644 index 00000000000..3a207b7d50a --- /dev/null +++ b/src/tools/miri/test-cargo-miri/no-std-smoke/src/main.rs @@ -0,0 +1,34 @@ +// Copied from tests/pass/no-std.rs + +#![feature(start)] +#![no_std] + +// Plumbing to let us use `writeln!` to host stdout: + +extern "Rust" { + fn miri_write_to_stdout(bytes: &[u8]); +} + +struct Host; + +use core::fmt::Write; + +impl Write for Host { + fn write_str(&mut self, s: &str) -> core::fmt::Result { + unsafe { + miri_write_to_stdout(s.as_bytes()); + } + Ok(()) + } +} + +#[start] +fn start(_: isize, _: *const *const u8) -> isize { + writeln!(Host, "hello, world!").unwrap(); + 0 +} + +#[panic_handler] +fn panic_handler(_: &core::panic::PanicInfo) -> ! { + loop {} +} |
