defmt_test/
export.rs

1use cortex_m_rt as _;
2use cortex_m_semihosting::debug;
3pub use defmt::info;
4
5use crate::TestOutcome;
6
7/// Terminates the application and makes a semihosting-capable debug tool exit
8/// with status code 0.
9pub fn exit() -> ! {
10    loop {
11        debug::exit(debug::EXIT_SUCCESS);
12    }
13}
14
15pub fn check_outcome<T: TestOutcome>(outcome: T, should_error: bool) {
16    if outcome.is_success() == should_error {
17        let note = if should_error {
18            defmt::intern!("`#[should_error]` ")
19        } else {
20            defmt::intern!("")
21        };
22        defmt::panic!("{}test failed with outcome: {}", note, outcome);
23    }
24}