mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-18 23:37:50 +00:00
Implement code for integration test post
This commit is contained in:
37
src/bin/test-basic-boot.rs
Normal file
37
src/bin/test-basic-boot.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
#![feature(panic_implementation)] // required for defining the panic handler
|
||||
#![feature(const_fn)]
|
||||
#![no_std] // don't link the Rust standard library
|
||||
#![cfg_attr(not(test), no_main)] // disable all Rust-level entry points
|
||||
|
||||
// add the library as dependency (same crate name as executable)
|
||||
#[macro_use]
|
||||
extern crate blog_os;
|
||||
|
||||
#[cfg(not(test))]
|
||||
use core::panic::PanicInfo;
|
||||
use blog_os::exit_qemu;
|
||||
|
||||
/// This function is the entry point, since the linker looks for a function
|
||||
/// named `_start_` by default.
|
||||
#[cfg(not(test))]
|
||||
#[no_mangle] // don't mangle the name of this function
|
||||
pub extern "C" fn _start() -> ! {
|
||||
serial_println!("ok");
|
||||
|
||||
unsafe { exit_qemu(); }
|
||||
loop {}
|
||||
}
|
||||
|
||||
|
||||
/// This function is called on panic.
|
||||
#[cfg(not(test))]
|
||||
#[panic_implementation]
|
||||
#[no_mangle]
|
||||
pub fn panic(info: &PanicInfo) -> ! {
|
||||
serial_println!("failed");
|
||||
|
||||
serial_println!("{}", info);
|
||||
|
||||
unsafe { exit_qemu(); }
|
||||
loop {}
|
||||
}
|
||||
Reference in New Issue
Block a user