Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
TestingAriel OS supports in-hardware testing using the embedded-test
crate. embedded-test
, used in conjunction with probe-rs
, serves as a replacement for the regular cargo test
based test harness, as the latter cannot be used on no_std
(embedded) devices. Please refer to the embedded-test
documentation for more info.
The build system of Ariel OS integrates the embedded-test
-based testing so that once set up, tests can be run by issuing laze build -b <board> test
. embedded-tests
can be used for any target that has probe-rs
support (which currently means all targets). Both async and non-async code can be tested.
Differences from vanillaCurrently, Ariel OS requires a fork of
embedded-test
. When using Ariel's build system, this will be used automatically.
embedded-test
In Ariel OS, the OS itself will start and initialize components before the tests are run. Logging, networking, ... will be available as for regular Ariel OS applications.
As a consequence, no Cargo features other than ariel-os
should be enabled on the embedded-test
dependency. In order to not require default-features = false
, the (default) panic-handler
feature is ignored when the ariel-os
feature is enabled.
embedded-test
for Ariel OS applications or libraries
Steps for enabling tests:
embedded-test
as a dev-dependency of your crate, and enable its ariel-os
Cargo feature, as follows:[dev-dependencies]
embedded-test = { version = "0.6.0", features = ["ariel-os"] }
This depends on whether a lib, a bin or a separate test should be tested.
Add the following to your Cargo.toml
:
# for a library crate
[lib]
harness = false
or
# for the default `bin`, "name" needs to match the package name
[[bin]]
name = "ariel-os-hello"
harness = false
or
# for a separate test in `test.rs`
[[test]]
name = "test"
harness = false
embedded-test
or embedded-test-only
laze module:apps:
# for an application:
- name: your-application
selects:
- embedded-test
# for a library:
- name: crate/your-library
selects:
- embedded-test-only
Even a library crate needs an entry in laze's
apps
in order to make thetest
task available. Selectingembedded-test-only
will make sure thatlaze run
is disabled.
lib.rs
, main.rs
or test.rs
:#![allow(unused)] fn main() { This goes to the top of the file #![no_main] #![no_std] }
#![allow(unused)] fn main() { #[cfg(test)] #[embedded_test::tests] mod tests { // Optional: An init function which is called before every test #[init] fn init() -> u32 { return 42; } // A test which takes the state returned by the init function (optional) // This is an async function, it will be executed on the system executor. #[test] async fn trivial_async(n: u32) { assert!(n == 42) } } }
Again, please refer to the embedded-test
documentation for more information.
To run a test, execute from within the crate's directory:
laze build -b <board> test
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4