mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-17 06:47:49 +00:00
Exit qemu after running tests
This commit is contained in:
15
src/main.rs
15
src/main.rs
@@ -24,6 +24,7 @@ fn test_runner(tests: &[&dyn Fn()]) {
|
||||
for test in tests {
|
||||
test();
|
||||
}
|
||||
unsafe { exit_qemu(QemuExitCode::Success) };
|
||||
}
|
||||
|
||||
/// This function is called on panic.
|
||||
@@ -33,6 +34,20 @@ fn panic(info: &PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum QemuExitCode {
|
||||
Success = 0x10,
|
||||
Failed = 0x11,
|
||||
}
|
||||
|
||||
pub unsafe fn exit_qemu(exit_code: QemuExitCode) {
|
||||
use x86_64::instructions::port::Port;
|
||||
|
||||
let mut port = Port::new(0xf4);
|
||||
port.write(exit_code as u32);
|
||||
}
|
||||
|
||||
#[test_case]
|
||||
fn trivial_assertion() {
|
||||
print!("trivial assertion... ");
|
||||
|
||||
Reference in New Issue
Block a user