|
| 1 | +//! This test runs a basic application for thumb targets, using the cortex-m crate. |
| 2 | +//! |
| 3 | +//! These targets are very bare-metal: the first instruction the core runs on |
| 4 | +//! power-on is already user code. The cortex-m-rt has to initialize the stack, .data, |
| 5 | +//! .bss, enable the FPU if present, etc. |
| 6 | +//! |
| 7 | +//! This test builds and runs the applications for various thumb targets using qemu. |
| 8 | +//! |
1 | 9 | //! How to run this
|
2 | 10 | //! $ ./x.py clean
|
3 | 11 | //! $ ./x.py test --target thumbv6m-none-eabi,thumbv7m-none-eabi tests/run-make
|
4 | 12 | //!
|
5 |
| -//! For supported targets, see `example/.cargo/config` |
| 13 | +//! For supported targets, see `example/.cargo/config.toml` |
| 14 | +//! |
| 15 | +//! FIXME: https://github.com/rust-lang/rust/issues/128733 this test uses external |
| 16 | +//! dependencies, and needs an active internet connection |
| 17 | +//! |
| 18 | +//! FIXME: https://github.com/rust-lang/rust/issues/128734 extract bootstrap cargo |
| 19 | +//! to a proper command |
6 | 20 |
|
7 | 21 | //@ only-thumb
|
8 | 22 |
|
9 | 23 | use std::path::PathBuf;
|
10 | 24 |
|
11 |
| -use run_make_support::{cmd, env_var}; |
| 25 | +use run_make_support::{cmd, env_var, path_helpers, target}; |
12 | 26 |
|
13 | 27 | const CRATE: &str = "example";
|
14 | 28 |
|
15 | 29 | fn main() {
|
16 | 30 | std::env::set_current_dir(CRATE).unwrap();
|
17 | 31 |
|
18 |
| - let target = env_var("TARGET"); |
19 | 32 | let bootstrap_cargo = env_var("BOOTSTRAP_CARGO");
|
20 | 33 | let path = env_var("PATH");
|
21 | 34 | let rustc = env_var("RUSTC");
|
22 | 35 |
|
23 |
| - let target_dir = PathBuf::from("target"); |
24 |
| - let manifest_path = PathBuf::from("Cargo.toml"); |
| 36 | + let target_dir = path_helpers::path("target"); |
| 37 | + let manifest_path = path_helpers::path("Cargo.toml"); |
25 | 38 |
|
26 | 39 | let debug = {
|
27 | 40 | let mut cmd = cmd(&bootstrap_cargo);
|
28 |
| - cmd.args(&["run", "--target", &target]) |
| 41 | + cmd.args(&["run", "--target", &target()]) |
29 | 42 | .env("RUSTFLAGS", "-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x")
|
30 | 43 | .env("CARGO_TARGET_DIR", &target_dir)
|
31 | 44 | .env("PATH", &path)
|
32 | 45 | .env("RUSTC", &rustc);
|
33 | 46 | cmd.run()
|
34 | 47 | };
|
35 | 48 |
|
36 |
| - let stdout = debug.stdout_utf8(); |
37 |
| - assert!(stdout.contains("x = 42"), "stdout: {:?}", stdout); |
| 49 | + debug.assert_stdout_contains("x = 42"); |
38 | 50 |
|
39 | 51 | let release = {
|
40 | 52 | let mut cmd = cmd(&bootstrap_cargo);
|
41 |
| - cmd.args(&["run", "--release", "--target", &target]) |
| 53 | + cmd.args(&["run", "--release", "--target", &target()]) |
42 | 54 | .env("RUSTFLAGS", "-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x")
|
43 | 55 | .env("CARGO_TARGET_DIR", &target_dir)
|
44 | 56 | .env("PATH", &path)
|
45 | 57 | .env("RUSTC", &rustc);
|
46 | 58 | cmd.run()
|
47 | 59 | };
|
48 | 60 |
|
49 |
| - let stdout = release.stdout_utf8(); |
50 |
| - assert!(stdout.contains("x = 42"), "stdout: {:?}", stdout); |
| 61 | + release.assert_stdout_contains("x = 42"); |
51 | 62 | }
|
0 commit comments