From a5b6422785f44218a261c069d8809331371cace1 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Thu, 25 Apr 2019 18:23:54 +0200 Subject: [PATCH] Add a test for the breakpoint exception --- src/interrupts.rs | 11 +++++++++++ src/lib.rs | 1 + 2 files changed, 12 insertions(+) diff --git a/src/interrupts.rs b/src/interrupts.rs index 745de3dc..3beff05e 100644 --- a/src/interrupts.rs +++ b/src/interrupts.rs @@ -23,3 +23,14 @@ pub fn init_idt() { extern "x86-interrupt" fn breakpoint_handler(stack_frame: &mut InterruptStackFrame) { println!("EXCEPTION: BREAKPOINT\n{:#?}", stack_frame); } + +#[cfg(test)] +use crate::{serial_print, serial_println}; + +#[test_case] +fn test_breakpoint_exception() { + serial_print!("test_breakpoint_exception..."); + // invoke a breakpoint exception + x86_64::instructions::interrupts::int3(); + serial_println!("[ok]"); +} diff --git a/src/lib.rs b/src/lib.rs index 55f3b457..28ac15df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -50,6 +50,7 @@ pub fn exit_qemu(exit_code: QemuExitCode) { #[cfg(test)] #[no_mangle] pub extern "C" fn _start() -> ! { + init(); test_main(); loop {} }