os-test-framework 0.2.0

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

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 {
    fn print(&mut self, args: Arguments);
    fn exit(&self, state: ExitState) -> !;
}