From 3e5885f7d2ad5c22a39b23e4b37b3b8483470e1e Mon Sep 17 00:00:00 2001 From: Folkert Date: Sun, 4 Aug 2024 22:24:20 +0200 Subject: [PATCH] changes after review --- .../example/.cargo/{config => config.toml} | 5 ++- tests/run-make/thumb-none-qemu/rmake.rs | 33 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) rename tests/run-make/thumb-none-qemu/example/.cargo/{config => config.toml} (90%) diff --git a/tests/run-make/thumb-none-qemu/example/.cargo/config b/tests/run-make/thumb-none-qemu/example/.cargo/config.toml similarity index 90% rename from tests/run-make/thumb-none-qemu/example/.cargo/config rename to tests/run-make/thumb-none-qemu/example/.cargo/config.toml index 8b30310e7d4..7152e81b502 100644 --- a/tests/run-make/thumb-none-qemu/example/.cargo/config +++ b/tests/run-make/thumb-none-qemu/example/.cargo/config.toml @@ -1,6 +1,5 @@ [target.thumbv6m-none-eabi] -# FIXME: Should be Cortex-M0, but Qemu used by CI is too old -runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel" +runner = "qemu-system-arm -cpu cortex-m0 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel" [target.thumbv7m-none-eabi] runner = "qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel" @@ -12,7 +11,7 @@ runner = "qemu-system-arm -cpu cortex-m4 -machine lm3s6965evb -nographic -semiho runner = "qemu-system-arm -cpu cortex-m4 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel" [target.thumbv8m.base-none-eabi] -# FIXME: Should be the Cortex-M23, bt Qemu does not currently support it +# FIXME: Should be the Cortex-M23, but Qemu does not currently support it runner = "qemu-system-arm -cpu cortex-m33 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel" [target.thumbv8m.main-none-eabi] diff --git a/tests/run-make/thumb-none-qemu/rmake.rs b/tests/run-make/thumb-none-qemu/rmake.rs index e280f5fafa5..d0f42bc8808 100644 --- a/tests/run-make/thumb-none-qemu/rmake.rs +++ b/tests/run-make/thumb-none-qemu/rmake.rs @@ -1,31 +1,44 @@ +//! 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. +//! //! How to run this //! $ ./x.py clean //! $ ./x.py test --target thumbv6m-none-eabi,thumbv7m-none-eabi tests/run-make //! -//! For supported targets, see `example/.cargo/config` +//! 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 //@ only-thumb use std::path::PathBuf; -use run_make_support::{cmd, env_var}; +use run_make_support::{cmd, env_var, path_helpers, target}; const CRATE: &str = "example"; fn main() { std::env::set_current_dir(CRATE).unwrap(); - let target = env_var("TARGET"); let bootstrap_cargo = env_var("BOOTSTRAP_CARGO"); let path = env_var("PATH"); let rustc = env_var("RUSTC"); - let target_dir = PathBuf::from("target"); - let manifest_path = PathBuf::from("Cargo.toml"); + let target_dir = path_helpers::path("target"); + let manifest_path = path_helpers::path("Cargo.toml"); let debug = { let mut cmd = cmd(&bootstrap_cargo); - cmd.args(&["run", "--target", &target]) + cmd.args(&["run", "--target", &target()]) .env("RUSTFLAGS", "-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x") .env("CARGO_TARGET_DIR", &target_dir) .env("PATH", &path) @@ -33,12 +46,11 @@ fn main() { cmd.run() }; - let stdout = debug.stdout_utf8(); - assert!(stdout.contains("x = 42"), "stdout: {:?}", stdout); + debug.assert_stdout_contains("x = 42"); let release = { let mut cmd = cmd(&bootstrap_cargo); - cmd.args(&["run", "--release", "--target", &target]) + cmd.args(&["run", "--release", "--target", &target()]) .env("RUSTFLAGS", "-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x") .env("CARGO_TARGET_DIR", &target_dir) .env("PATH", &path) @@ -46,6 +58,5 @@ fn main() { cmd.run() }; - let stdout = release.stdout_utf8(); - assert!(stdout.contains("x = 42"), "stdout: {:?}", stdout); + release.assert_stdout_contains("x = 42"); }