mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
39 lines
830 B
Rust
39 lines
830 B
Rust
#![no_std]
|
|
#![no_main]
|
|
#![feature(custom_test_frameworks)]
|
|
#![test_runner(test_runner)]
|
|
#![reexport_test_harness_main = "test_main"]
|
|
|
|
use blog_os::{exit_qemu, serial_print, serial_println, QemuExitCode};
|
|
use core::panic::PanicInfo;
|
|
|
|
#[no_mangle]
|
|
pub extern "C" fn _start() -> ! {
|
|
test_main();
|
|
|
|
loop {}
|
|
}
|
|
|
|
pub fn test_runner(tests: &[&dyn Fn()]) {
|
|
serial_println!("Running {} tests", tests.len());
|
|
if let Some(test) = tests.first() {
|
|
test();
|
|
serial_println!("[test did not panic]");
|
|
exit_qemu(QemuExitCode::Failed);
|
|
}
|
|
exit_qemu(QemuExitCode::Success);
|
|
}
|
|
|
|
#[panic_handler]
|
|
fn panic(_info: &PanicInfo) -> ! {
|
|
serial_println!("[ok]");
|
|
exit_qemu(QemuExitCode::Success);
|
|
loop {}
|
|
}
|
|
|
|
#[test_case]
|
|
fn should_fail() {
|
|
serial_print!("should_fail... ");
|
|
assert_eq!(0, 1);
|
|
}
|