1
0
Fork 0
forked from AbleOS/ableos

Ktest log fixes, maybe arm?

This commit is contained in:
FunkyEgg 2024-11-25 17:28:49 +11:00
parent d52f14ee1f
commit de817e2c4d
No known key found for this signature in database
3 changed files with 15 additions and 6 deletions

View file

@ -7,6 +7,11 @@ SECTIONS
.text : { *(.text) } .text : { *(.text) }
.data : { *(.data) } .data : { *(.data) }
.rodata : { *(.rodata) } .rodata : { *(.rodata) }
.note.ktest : {
__ktest_start = .;
*(.note.ktest)
__ktest_end = .;
}
.bss : { .bss : {
*(COMMON) *(COMMON)
*(.bss .bss.*) *(.bss .bss.*)

View file

@ -23,8 +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::test_main; use {
debug!("Running tests"); crate::ktest::test_main,
log::info,
};
info!("Running tests");
test_main(); test_main();
loop {} loop {}

View file

@ -1,6 +1,6 @@
use { use {
alloc::string::String, alloc::string::String,
log::debug, log::{info, error},
}; };
pub use ktest_macro::*; pub use ktest_macro::*;
@ -15,6 +15,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 // Should panic tests
// Test specific panic handler
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,11 +30,11 @@ pub fn test_main() {
let test_name = test_fn(); let test_name = test_fn();
match test_name { match test_name {
Ok(name) => { Ok(name) => {
debug!("Test: {} passed", name); info!("Test: {} passed", name);
pass += 1; pass += 1;
}, },
Err(name) => { Err(name) => {
debug!("Test: {} failed", name); error!("Test: {} failed", name);
fail += 1; fail += 1;
} }
} }
@ -41,7 +42,7 @@ pub fn test_main() {
current_test = current_test.add(1); current_test = current_test.add(1);
} }
debug!("{}/{} tests passed", pass, pass + fail); info!("{}/{} tests passed", pass, pass + fail);
} }
} }