Skip to content

Commit

Permalink
Auto merge of rust-lang#2690 - Nilstrieb:cargo-miri-smoke-test-ci-so-…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
bors committed Nov 26, 2022
2 parents fa91fa7 + d9b7035 commit c2eac58
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test-cargo-miri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
7 changes: 7 additions & 0 deletions test-cargo-miri/no-std-smoke/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions test-cargo-miri/no-std-smoke/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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'
34 changes: 34 additions & 0 deletions test-cargo-miri/no-std-smoke/src/main.rs
Original file line number Diff line number Diff line change
@@ -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 {}
}

0 comments on commit c2eac58

Please sign in to comment.