XeOS/src/main.rs

36 lines
672 B
Rust

#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(xe_os::test_runner)]
#![reexport_test_harness_main = "test_main"]
use core::panic::PanicInfo;
use xe_os::println;
#[no_mangle]
pub extern "C" fn _start() -> ! {
xe_os::init();
println!("Hello World{}", "!");
#[cfg(test)]
test_main();
println!("It did not crash!");
loop {}
}
// our existing panic handler
#[cfg(not(test))] // new attribute
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
println!("{}", info);
loop {}
}
// our panic handler in test mode
#[cfg(test)]
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
xe_os::test_panic_handler(info);
}