rust/tests/run-make/thumb-none-qemu/rmake.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
2.0 KiB
Rust
Raw Normal View History

2024-08-04 15:24:20 -05:00
//! This test runs a basic application for thumb targets, using the cortex-m crate.
//!
//! These targets are very bare-metal: the first instruction the core runs on
//! power-on is already user code. The cortex-m-rt has to initialize the stack, .data,
//! .bss, enable the FPU if present, etc.
//!
//! This test builds and runs the applications for various thumb targets using qemu.
//!
2024-08-04 06:59:11 -05:00
//! How to run this
//! $ ./x.py clean
//! $ ./x.py test --target thumbv6m-none-eabi,thumbv7m-none-eabi tests/run-make
//!
2024-08-04 15:24:20 -05:00
//! For supported targets, see `example/.cargo/config.toml`
//!
//! FIXME: https://github.com/rust-lang/rust/issues/128733 this test uses external
//! dependencies, and needs an active internet connection
//!
//! FIXME: https://github.com/rust-lang/rust/issues/128734 extract bootstrap cargo
//! to a proper command
2024-08-04 06:59:11 -05:00
//@ only-thumb
use std::path::PathBuf;
2024-08-04 15:24:20 -05:00
use run_make_support::{cmd, env_var, path_helpers, target};
2024-08-04 06:59:11 -05:00
const CRATE: &str = "example";
fn main() {
std::env::set_current_dir(CRATE).unwrap();
let bootstrap_cargo = env_var("BOOTSTRAP_CARGO");
let path = env_var("PATH");
let rustc = env_var("RUSTC");
2024-08-04 15:24:20 -05:00
let target_dir = path_helpers::path("target");
let manifest_path = path_helpers::path("Cargo.toml");
2024-08-04 06:59:11 -05:00
let debug = {
let mut cmd = cmd(&bootstrap_cargo);
2024-08-04 15:24:20 -05:00
cmd.args(&["run", "--target", &target()])
2024-08-04 06:59:11 -05:00
.env("RUSTFLAGS", "-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x")
.env("CARGO_TARGET_DIR", &target_dir)
.env("PATH", &path)
.env("RUSTC", &rustc);
cmd.run()
};
2024-08-04 15:24:20 -05:00
debug.assert_stdout_contains("x = 42");
2024-08-04 06:59:11 -05:00
let release = {
let mut cmd = cmd(&bootstrap_cargo);
2024-08-04 15:24:20 -05:00
cmd.args(&["run", "--release", "--target", &target()])
2024-08-04 06:59:11 -05:00
.env("RUSTFLAGS", "-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x")
.env("CARGO_TARGET_DIR", &target_dir)
.env("PATH", &path)
.env("RUSTC", &rustc);
cmd.run()
};
2024-08-04 15:24:20 -05:00
release.assert_stdout_contains("x = 42");
2024-08-04 06:59:11 -05:00
}