mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-17 06:47:49 +00:00
Create new post about unit testing
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -1,18 +1,25 @@
|
||||
#![feature(lang_items)] // required for defining the panic handler
|
||||
#![feature(const_fn)] // allow declaring functions as const
|
||||
#![no_std] // don't link the Rust standard library
|
||||
#![no_main] // disable all Rust-level entry points
|
||||
#![cfg_attr(not(test), no_main)] // disable all Rust-level entry points
|
||||
#![cfg_attr(test, allow(dead_code, unused_macros))] // allow unused code in test mode
|
||||
|
||||
extern crate spin;
|
||||
extern crate volatile;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate array_init;
|
||||
#[cfg(test)]
|
||||
extern crate std;
|
||||
|
||||
#[macro_use]
|
||||
mod vga_buffer;
|
||||
|
||||
/// 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() -> ! {
|
||||
println!("Hello World{}", "!");
|
||||
@@ -21,6 +28,7 @@ pub extern "C" fn _start() -> ! {
|
||||
}
|
||||
|
||||
/// This function is called on panic.
|
||||
#[cfg(not(test))]
|
||||
#[lang = "panic_fmt"]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn rust_begin_panic(
|
||||
|
||||
Reference in New Issue
Block a user