diff options
| -rw-r--r-- | StrixKernel/tests/basic_boot.rs | 25 | ||||
| -rw-r--r-- | StrixKernel/tests/should_panic.rs | 25 |
2 files changed, 50 insertions, 0 deletions
diff --git a/StrixKernel/tests/basic_boot.rs b/StrixKernel/tests/basic_boot.rs new file mode 100644 index 0000000..e29dcea --- /dev/null +++ b/StrixKernel/tests/basic_boot.rs @@ -0,0 +1,25 @@ +#![no_std] +#![no_main] +#![feature(custom_test_frameworks)] +#![test_runner(strix_os::test_runner)] +#![reexport_test_harness_main = "test_main"] + +use strix_os::println; +use core::panic::PanicInfo; + +#[unsafe(no_mangle)] // don't mangle the name of this function +pub extern "C" fn _start() -> ! { + test_main(); + + loop {} +} + +#[panic_handler] +fn panic(info: &PanicInfo) -> ! { + strix_os::test_panic_handler(info) +} + +#[test_case] +fn test_println() { + println!("test_println output"); +}
\ No newline at end of file diff --git a/StrixKernel/tests/should_panic.rs b/StrixKernel/tests/should_panic.rs new file mode 100644 index 0000000..3cbe0a8 --- /dev/null +++ b/StrixKernel/tests/should_panic.rs @@ -0,0 +1,25 @@ +#![no_std] +#![no_main] + +use strix_os::{QemuExitCode, exit_qemu, serial_print, serial_println}; +use core::panic::PanicInfo; + +#[unsafe(no_mangle)] +pub extern "C" fn _start() -> ! { + should_fail(); + serial_println!("[test did not panic]"); + exit_qemu(QemuExitCode::Failed); + loop {} +} + +fn should_fail() { + serial_print!("should_panic::should_fail...\t"); + assert_eq!(0, 1); +} + +#[panic_handler] +fn panic(_info: &PanicInfo) -> ! { + serial_println!("[ok]"); + exit_qemu(QemuExitCode::Success); + loop {} +}
\ No newline at end of file |
