pub use ktest_macro::*; use { alloc::string::String, log::{error, info}, }; extern "C" { static __ktest_start: fn() -> Result; static __ktest_end: fn() -> Result; } // TODO: Implement ktest for arm and riscv (Later problems, see below) // Allow for arch specific tests (Leave for now) // Should panic tests // Test specific panic handler pub fn test_main() { unsafe { let mut current_test = &__ktest_start as *const fn() -> Result; let test_end = &__ktest_end as *const fn() -> Result; let mut pass = 0; let mut fail = 0; while current_test < test_end { let test_fn = *current_test; let test_name = test_fn(); match test_name { Ok(name) => { info!("Test: {} passed", name); pass += 1; }, Err(name) => { error!("Test: {} failed", name); fail += 1; } } current_test = current_test.add(1); } info!("{}/{} tests passed", pass, pass + fail); } } #[ktest] pub fn trivial_assertion() { ktest_eq!(1, 1); ktest_neq!(0, 1); }