Skip to content

Commit 36fc08e

Browse files
committed
Add on-target tests to CI
1 parent 6b01313 commit 36fc08e

File tree

15 files changed

+585
-1
lines changed

15 files changed

+585
-1
lines changed

.cargo/config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
2+
rustflags = ["-C", "link-arg=-Tlink.x"]
3+
14
[alias]
25
xtask = "run --package xtask --bin xtask --"

.github/workflows/on-target.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
on:
2+
push:
3+
branches: [ staging, trying, master ]
4+
pull_request:
5+
6+
name: On target tests
7+
8+
jobs:
9+
on-target:
10+
runs-on: self-hosted
11+
steps:
12+
- name: Display rustup version
13+
run: rustup --version
14+
- name: Display probe-run version
15+
run: probe-run --version
16+
- name: List probes
17+
run: probe-run --list-probes
18+
- uses: actions/checkout@v2
19+
with:
20+
submodules: true
21+
- name: Setup toolchain
22+
run: rustup default stable && rustup target install thumbv6m-none-eabi
23+
- name: Build on-target tests
24+
run: cargo build -p testsuite --target thumbv6m-none-eabi
25+
- name: Run on-target tests
26+
run: probe-run --chip STM32F070RBTx --connect-under-reset target/thumbv6m-none-eabi/debug/testsuite

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "cortex-m-rt"]
2+
path = cortex-m-rt
3+
url = [email protected]:newAM/cortex-m-rt.git

Cargo.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ inline-asm = []
2828
linker-plugin-lto = []
2929

3030
[workspace]
31-
members = ["xtask", "cortex-m-semihosting", "panic-semihosting", "panic-itm"]
31+
members = [
32+
"cortex-m-rt",
33+
"cortex-m-semihosting",
34+
"panic-itm",
35+
"panic-semihosting",
36+
"testsuite",
37+
"testsuite/minitest",
38+
"testsuite/minitest/macros",
39+
"xtask",
40+
]
3241

3342
[package.metadata.docs.rs]
3443
targets = [

cortex-m-rt

Submodule cortex-m-rt added at 2a12b88

memory.x

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* Memory layout for the STM32F070RBTx used for on-target testing */
2+
MEMORY
3+
{
4+
FLASH : ORIGIN = 0x8000000, LENGTH = 128K
5+
RAM : ORIGIN = 0x20000000, LENGTH = 16K
6+
}

testsuite/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
authors = ["The Cortex-M Team <[email protected]>"]
3+
name = "testsuite"
4+
publish = false
5+
edition = "2018"
6+
version = "0.1.0"
7+
8+
[dependencies]
9+
cortex-m-rt.path = "../cortex-m-rt"
10+
cortex-m.path = ".."
11+
minitest.path = "minitest"
12+
rtt-target = "0.3.1"

testsuite/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Testsuite
2+
3+
This workspace contains on-target tests.
4+
5+
## Building
6+
7+
Assuming you are at the root of the repository you can build like this:
8+
9+
```console
10+
$ cargo build -p testsuite --target thumbv6m-none-eabi
11+
Compiling testsuite v0.1.0 (cortex-m/testsuite)
12+
Finished dev [unoptimized + debuginfo] target(s) in 0.08
13+
```
14+
15+
## Running
16+
17+
No implementation-specific features are tested right now; any `thumbv6m-none-eabi` target should work.
18+
19+
Tests are executed with [probe-run](https://github.com/knurling-rs/probe-run):
20+
21+
```console
22+
$ probe-run --chip STM32F070RBTx --connect-under-reset target/thumbv6m-none-eabi/debug/testsuite
23+
(HOST) INFO flashing program (12.80 KiB)
24+
(HOST) INFO success!
25+
────────────────────────────────────────────────────────────────────────────────
26+
(1/2) running `assert_true`...
27+
(2/2) running `assert_flag`...
28+
all tests passed!
29+
────────────────────────────────────────────────────────────────────────────────
30+
stack backtrace:
31+
0: lib::inline::__bkpt
32+
at ./asm/inline.rs:13:5
33+
1: __bkpt
34+
at ./asm/lib.rs:49:17
35+
2: minitest::export::exit
36+
at testsuite/minitest/src/export.rs:6:9
37+
3: main
38+
at testsuite/src/main.rs:23:1
39+
4: Reset
40+
(HOST) WARN call stack was corrupted; unwinding could not be completed
41+
(HOST) INFO device halted without error
42+
```
43+
44+
## CI
45+
46+
These tests are run automatically in continuous integration. A self-hosted github actions runner with a NUCLEO-F070RB board is hosted by [newAM](https://github.com/newAM).
47+
48+
The runner is equiped with a limited selection of packages:
49+
* [Unix Commands](https://en.wikipedia.org/wiki/List_of_Unix_commands)
50+
* clang
51+
* gcc-arm-embedded
52+
* git
53+
* probe-run
54+
* rustup
55+
56+
The complete host configuration can be found here [here](https://github.com/newAM/nixfiles/blob/main/t430s/configuration.nix).
57+
58+
⚠️ Hosting a github actions runner in a public repository goes directly against [github's advice](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners#self-hosted-runner-security-with-public-repositories), do not do this yourself unless you are prepared to accept the risks.

testsuite/minitest/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
authors = ["The Cortex-M Team <[email protected]>"]
3+
name = "minitest"
4+
publish = false
5+
edition = "2018"
6+
version = "0.1.0"
7+
8+
[dependencies]
9+
cortex-m.path = "../.."
10+
cortex-m-rt.path = "../../cortex-m-rt"
11+
minitest-macros = { version = "=0.1.0", path = "macros" }
12+
rtt-target = "0.3.1"

testsuite/minitest/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# rtt-test
2+
3+
This is an embedded test framework forked from knurling's excellent [`defmt-test`] crate.
4+
5+
This even more minimal than [`defmt-test`] to allow for for testing of this crate without dependency cycles.
6+
7+
[`defmt-test`]: https://crates.io/crates/defmt-test/

0 commit comments

Comments
 (0)