From de817e2c4d35d1474449c676ed8d275d07fc3e1e Mon Sep 17 00:00:00 2001 From: FunkyEgg Date: Mon, 25 Nov 2024 17:28:49 +1100 Subject: [PATCH] Ktest log fixes, maybe arm? --- kernel/lds/aarch64-qemu.ld | 5 +++++ kernel/src/kmain.rs | 7 +++++-- kernel/src/ktest.rs | 9 +++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/kernel/lds/aarch64-qemu.ld b/kernel/lds/aarch64-qemu.ld index dbcbacf..a61d5e8 100644 --- a/kernel/lds/aarch64-qemu.ld +++ b/kernel/lds/aarch64-qemu.ld @@ -7,6 +7,11 @@ SECTIONS .text : { *(.text) } .data : { *(.data) } .rodata : { *(.rodata) } + .note.ktest : { + __ktest_start = .; + *(.note.ktest) + __ktest_end = .; + } .bss : { *(COMMON) *(.bss .bss.*) diff --git a/kernel/src/kmain.rs b/kernel/src/kmain.rs index 1248ef5..e7dbdbc 100644 --- a/kernel/src/kmain.rs +++ b/kernel/src/kmain.rs @@ -23,8 +23,11 @@ pub fn kmain(_cmdline: &str, boot_modules: BootModules) -> ! { debug!("Entered kmain"); #[cfg(feature = "ktest")] { - use crate::ktest::test_main; - debug!("Running tests"); + use { + crate::ktest::test_main, + log::info, + }; + info!("Running tests"); test_main(); loop {} diff --git a/kernel/src/ktest.rs b/kernel/src/ktest.rs index 5c460a3..f8cef6d 100644 --- a/kernel/src/ktest.rs +++ b/kernel/src/ktest.rs @@ -1,6 +1,6 @@ use { alloc::string::String, - log::debug, + log::{info, error}, }; pub use ktest_macro::*; @@ -15,6 +15,7 @@ extern "C" { // 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; @@ -29,11 +30,11 @@ pub fn test_main() { let test_name = test_fn(); match test_name { Ok(name) => { - debug!("Test: {} passed", name); + info!("Test: {} passed", name); pass += 1; }, Err(name) => { - debug!("Test: {} failed", name); + error!("Test: {} failed", name); fail += 1; } } @@ -41,7 +42,7 @@ pub fn test_main() { current_test = current_test.add(1); } - debug!("{}/{} tests passed", pass, pass + fail); + info!("{}/{} tests passed", pass, pass + fail); } }