blog_os/tests/should_panic.rs

26 lines
501 B
Rust
Raw Normal View History

2019-09-24 13:38:25 -04:00
#![no_std]
#![no_main]
2019-10-01 13:53:03 -04:00
use blog_os::{exit_qemu, serial_print, serial_println, QemuExitCode};
2019-09-24 13:38:25 -04:00
use core::panic::PanicInfo;
#[no_mangle]
pub extern "C" fn _start() -> ! {
should_fail();
serial_println!("[test did not panic]");
2019-10-01 13:53:03 -04:00
exit_qemu(QemuExitCode::Failed);
2019-09-24 13:38:25 -04:00
loop {}
}
fn should_fail() {
serial_print!("should_fail... ");
assert_eq!(0, 1);
}
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
serial_println!("[ok]");
exit_qemu(QemuExitCode::Success);
loop {}
2019-10-01 13:53:03 -04:00
}