embedded_test_harness

Crates.ioembedded_test_harness
lib.rsembedded_test_harness
version0.1.1
sourcesrc
created_at2022-06-28 09:42:24.283484
updated_at2022-06-28 11:51:42.653169
descriptionRust no_std test harness
homepage
repositoryhttps://github.com/aiooss-ledger/embedded_test_harness/
max_upload_size
id614731
size6,255
(erdnaxe)

documentation

README

Embedded test harness for Rust no_std

Only supports ARM Cortex-M semi-hosting for now.

How to use

Add embedded_test_harness and testmacro = { git = "https://github.com/yhql/testmacro"} to Cargo.toml dev-dependencies.

Then you may write tests following this template:

#![no_std]
#![cfg_attr(test, no_main)]
#![reexport_test_harness_main = "test_main"]
#![feature(custom_test_frameworks)]
#![test_runner(test_runner)]

use panic_semihosting as _;

#[cfg(test)]
use embedded_test_harness::test_runner;

#[cfg(test)]
mod tests {
    use testmacro::test_item as test;
    use embedded_test_harness::TestType;

    #[test]
    fn it_works() {
        let result = 2 + 2;
        assert_eq!(result, 4);
    }
}

/// _start is the entrypoint specified in the linker
#[no_mangle]
pub fn _start() -> ! {
    #[cfg(test)]
    test_main();

    loop {}
}

References

Commit count: 11

cargo fmt