Skip to content

Commit 4d3e565

Browse files
committed
Auto merge of #2690 - Nilstrieb:cargo-miri-smoke-test-ci-so-that-cargo-miri-actually-works-kinda, r=RalfJung
Test a small cargo-miri smoke test even in `run_tests_minimal` This makes sure that cargo-miri works on all targets. Implements the first step of rust-lang/miri#2685 (comment) to get that PR tested.
2 parents 7d0db1e + 166e60e commit 4d3e565

File tree

5 files changed

+60
-0
lines changed

5 files changed

+60
-0
lines changed

src/tools/miri/ci.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ function run_tests_minimal {
7373
fi
7474

7575
./miri test -- "$@"
76+
77+
# Ensure that a small smoke test of cargo-miri works.
78+
# Note: This doesn't work on windows because of TLS.
79+
cargo miri run --manifest-path test-cargo-miri/no-std-smoke/Cargo.toml
7680
}
7781

7882
# host

src/tools/miri/test-cargo-miri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[workspace]
22
members = ["subcrate", "issue-1567", "exported-symbol-dep"]
3+
exclude = ["no-std-smoke"] # it wants to be panic="abort"
34

45
[package]
56
name = "cargo-miri-test"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file is automatically @generated by Cargo.
2+
# It is not intended for manual editing.
3+
version = 3
4+
5+
[[package]]
6+
name = "no-std-smoke"
7+
version = "0.1.0"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "no-std-smoke"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
10+
[profile.dev]
11+
panic = 'abort'
12+
13+
[profile.release]
14+
panic = 'abort'
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copied from tests/pass/no-std.rs
2+
3+
#![feature(start)]
4+
#![no_std]
5+
6+
// Plumbing to let us use `writeln!` to host stdout:
7+
8+
extern "Rust" {
9+
fn miri_write_to_stdout(bytes: &[u8]);
10+
}
11+
12+
struct Host;
13+
14+
use core::fmt::Write;
15+
16+
impl Write for Host {
17+
fn write_str(&mut self, s: &str) -> core::fmt::Result {
18+
unsafe {
19+
miri_write_to_stdout(s.as_bytes());
20+
}
21+
Ok(())
22+
}
23+
}
24+
25+
#[start]
26+
fn start(_: isize, _: *const *const u8) -> isize {
27+
writeln!(Host, "hello, world!").unwrap();
28+
0
29+
}
30+
31+
#[panic_handler]
32+
fn panic_handler(_: &core::panic::PanicInfo) -> ! {
33+
loop {}
34+
}

0 commit comments

Comments
 (0)