anos/tests/should_panic.rs
2022-01-13 12:11:03 +08:00

26 lines
513 B
Rust

#![no_std]
#![no_main]
use anos::{exit_qemu, serial_print, serial_println, QemuExitCode};
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
serial_println!("\t[ok]");
exit_qemu(QemuExitCode::Success);
loop {}
}
fn should_fail() {
serial_print!("should_panic::should_fail...");
assert_eq!(0, 1);
}
#[no_mangle]
pub extern "C" fn _start() -> ! {
should_fail();
serial_println!("[test did not panic]");
exit_qemu(QemuExitCode::Failed);
loop {}
}