-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
85: Remove raw-cpuid dependency and use rdrand intrinsics r=phil-opp a=64 This reduces my compile times from scratch from about 215s to 160s. 86: Update integration tests to use new testing framework r=phil-opp a=phil-opp Use `cargo xtest` and `bootimage runner` instead of the old `bootimage test` for testing. See https://os.phil-opp.com/testing/ for more information on the approach. Co-authored-by: Matt Taylor <mstaveleytaylor@gmail.com> Co-authored-by: Philipp Oppermann <dev@phil-opp.com>
- Loading branch information
Showing
14 changed files
with
206 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[build] | ||
target = "x86_64-bare-metal.json" | ||
|
||
[target.'cfg(target_os = "none")'] | ||
runner = "bootimage runner" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,56 @@ | ||
#![cfg_attr(test, no_main)] | ||
#![feature(custom_test_frameworks)] | ||
#![test_runner(crate::test_runner)] | ||
#![reexport_test_harness_main = "test_main"] | ||
#![no_std] | ||
|
||
extern crate spin; | ||
extern crate uart_16550; | ||
extern crate x86_64; | ||
#[macro_use] | ||
extern crate lazy_static; | ||
use core::panic::PanicInfo; | ||
|
||
#[macro_use] | ||
pub mod serial; | ||
pub mod gdt; | ||
mod tests; | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
#[repr(u32)] | ||
pub enum QemuExitCode { | ||
Success = 0x10, | ||
Failed = 0x11, | ||
} | ||
|
||
pub fn exit_qemu(exit_code: QemuExitCode) { | ||
use x86_64::instructions::port::Port; | ||
|
||
unsafe { | ||
let mut port = Port::new(0xf4); | ||
port.write(exit_code as u32); | ||
} | ||
} | ||
|
||
pub fn test_runner(tests: &[&dyn Fn()]) { | ||
serial_println!("Running {} tests", tests.len()); | ||
for test in tests { | ||
test(); | ||
} | ||
exit_qemu(QemuExitCode::Success); | ||
} | ||
|
||
use x86_64::instructions::port::Port; | ||
pub fn test_panic_handler(info: &PanicInfo) -> ! { | ||
serial_println!("[failed]\n"); | ||
serial_println!("Error: {}\n", info); | ||
exit_qemu(QemuExitCode::Failed); | ||
loop {} | ||
} | ||
|
||
#[cfg(test)] | ||
#[no_mangle] | ||
pub extern "C" fn _start() -> ! { | ||
test_main(); | ||
loop {} | ||
} | ||
|
||
pub unsafe fn exit_qemu() { | ||
let mut port = Port::<u32>::new(0xf4); | ||
port.write(0); | ||
#[cfg(test)] | ||
#[panic_handler] | ||
fn panic(info: &PanicInfo) -> ! { | ||
test_panic_handler(info) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#[test_case] | ||
fn example_test() { | ||
serial_print!("example_test... "); | ||
assert_eq!(0, 0); | ||
serial_println!("[ok]"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#![no_std] | ||
#![no_main] | ||
#![feature(custom_test_frameworks)] | ||
#![reexport_test_harness_main = "test_main"] | ||
#![test_runner(testing::test_runner)] | ||
|
||
use core::panic::PanicInfo; | ||
use testing::{serial_print, serial_println}; | ||
|
||
#[no_mangle] // don't mangle the name of this function | ||
pub extern "C" fn _start() -> ! { | ||
test_main(); | ||
|
||
loop {} | ||
} | ||
|
||
#[panic_handler] | ||
fn panic(info: &PanicInfo) -> ! { | ||
testing::test_panic_handler(info) | ||
} | ||
|
||
#[test_case] | ||
fn basic_boot() { | ||
serial_print!("basic_boot... "); | ||
assert_eq!(0, 0); | ||
serial_println!("[ok]"); | ||
} |
Oops, something went wrong.