Exit qemu after running tests

This commit is contained in:
Philipp Oppermann
2019-04-20 18:32:58 +02:00
parent 3aa6151729
commit dbdd46da9a
3 changed files with 73 additions and 0 deletions

View File

@@ -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... ");