Ktest major improvements #21

Closed
funky wants to merge 5 commits from funky/ableos:ktest into master
2 changed files with 9 additions and 6 deletions
Showing only changes of commit d52f14ee1f - Show all commits

View file

@ -23,11 +23,11 @@ pub fn kmain(_cmdline: &str, boot_modules: BootModules) -> ! {
debug!("Entered kmain"); debug!("Entered kmain");
#[cfg(feature = "ktest")] { #[cfg(feature = "ktest")] {
use crate::ktest; use crate::ktest::test_main;
debug!("TESTING"); debug!("Running tests");
ktest::test_main(); test_main();
loop {}; loop {}
} }
// let kcmd = build_cmd("Kernel Command Line", cmdline); // let kcmd = build_cmd("Kernel Command Line", cmdline);

View file

@ -5,6 +5,8 @@ use {
pub use ktest_macro::*; pub use ktest_macro::*;
#[allow(improper_ctypes)]
extern "C" { extern "C" {
static __ktest_start: fn() -> Result<String, String>; static __ktest_start: fn() -> Result<String, String>;
static __ktest_end: fn() -> Result<String, String>; static __ktest_end: fn() -> Result<String, String>;
@ -12,6 +14,7 @@ extern "C" {
// TODO: Implement ktest for arm and riscv (Later problems, see below) // TODO: Implement ktest for arm and riscv (Later problems, see below)
// Allow for arch specific tests (Leave for now) // Allow for arch specific tests (Leave for now)
// Should panic tests
pub fn test_main() { pub fn test_main() {
unsafe { unsafe {
let mut current_test = &__ktest_start as *const fn() -> Result<String, String>; let mut current_test = &__ktest_start as *const fn() -> Result<String, String>;
@ -29,8 +32,8 @@ pub fn test_main() {
debug!("Test: {} passed", name); debug!("Test: {} passed", name);
pass += 1; pass += 1;
}, },
Err(ename) => { Err(name) => {
debug!("Test: {} failed", ename); debug!("Test: {} failed", name);
fail += 1; fail += 1;
} }
} }