os-test-framework 0.1.2

Test framework for embedded systems and OS kernels.
Documentation
use core::fmt::Write;

use alloc::boxed::Box;
use spin::{Mutex, Once};

static PLATFORM: Once<Mutex<Box<dyn Platform>>> = Once::new();

pub fn init_platform(platform: impl Platform + 'static) {
    PLATFORM.call_once(|| Mutex::new(Box::new(platform)));
}

pub fn platform() -> &'static Mutex<Box<dyn Platform>> {
    PLATFORM.get().unwrap()
}

pub enum ExitState {
    Success,
    Failed,
}
pub trait Platform: Send + Sync + Write {
    fn exit(&self, state: ExitState) -> !;
}