diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..a5796d0 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,16 @@ +#![no_std] +#![cfg_attr(test, no_main)] +#![feature(custom_test_frameworks)] +#![test_runner(crate::test_utils::test_runner)] +#![reexport_test_harness_main = "test_main"] + +pub mod test_utils; +pub mod serial; +pub mod vga_buffer; + +#[cfg(test)] +#[no_mangle] +pub extern "C" fn _start() { + test_main(); + loop {} +} diff --git a/src/main.rs b/src/main.rs index 0b6f0bb..bef4635 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,8 +20,8 @@ fn panic(info: &core::panic::PanicInfo) -> ! { #[no_mangle] pub extern "C" fn _start() -> ! { - #[cfg(test)] - test_main(); + // #[cfg(test)] + // test_main(); println!("Gamarjoba, munde!"); loop {} diff --git a/src/test_utils.rs b/src/test_utils.rs index 6411707..930dd1a 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -3,7 +3,7 @@ use core::panic::PanicInfo; #[panic_handler] -fn panic(info: &PanicInfo) -> ! { +pub fn panic(info: &PanicInfo) -> ! { serial_println!("[failed]\n"); serial_println!("Error: {}", info); exit_qemu(QemuExitCode::Failed); diff --git a/tests/basic_boot.rs b/tests/basic_boot.rs new file mode 100644 index 0000000..c3608de --- /dev/null +++ b/tests/basic_boot.rs @@ -0,0 +1,23 @@ +#![no_std] +#![no_main] +#![feature(custom_test_frameworks)] +#![test_runner(crate::test_utils::test_runner)] +#![reexport_test_harness_main = "test_main"] + +use core::panic::PanicInfo; + +#[no_mangle] // don't mangle the name of this function +pub extern "C" fn _start() -> ! { + test_main(); + + loop {} +} + +fn test_runner(tests: &[&dyn Fn()]) { + unimplemented!(); +} + +#[panic_handler] +fn panic(info: &PanicInfo) -> ! { + loop {} +}