From e5efe96ffb77a6cb59256ceb2f7a5c6e68897c8f Mon Sep 17 00:00:00 2001 From: guillaume didier Date: Wed, 13 Nov 2019 14:12:28 +0100 Subject: [PATCH] Use entry_point! in all tests* --- src/lib.rs | 12 ++++++++++-- tests/basic_boot.rs | 11 +++++++++-- tests/panic_test.rs | 10 ++++++++-- tests/sse_interrupt_test.rs | 10 ++++++++-- tests/stack_overflow.rs | 9 +++++++-- 5 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 55d4950..3d1f222 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,9 +65,17 @@ pub fn hlt_loop() -> ! { } } + #[cfg(test)] -#[no_mangle] -pub extern "C" fn _start() -> ! { +use bootloader::{entry_point, BootInfo}; + +#[cfg(test)] +entry_point!(test_kernel_main); + +/// Entry point for `cargo xtest` +#[cfg(test)] +fn test_kernel_main(_boot_info: &'static BootInfo) -> ! { + init(); test_main(); loop {} } diff --git a/tests/basic_boot.rs b/tests/basic_boot.rs index 7ef41e7..2aec38b 100644 --- a/tests/basic_boot.rs +++ b/tests/basic_boot.rs @@ -8,8 +8,15 @@ use core::panic::PanicInfo; use polling_serial::{serial_print, serial_println}; use vga_buffer::{print, println}; -#[no_mangle] // don't mangle the name of this function -pub extern "C" fn _start() -> ! { + +use bootloader::{entry_point, BootInfo}; + +entry_point!(test_kernel_main); + +/// Entry point for `cargo xtest` + +fn test_kernel_main(_boot_info: &'static BootInfo) -> ! { + dendrobates_tinctoreus_azureus::init(); test_main(); loop {} diff --git a/tests/panic_test.rs b/tests/panic_test.rs index 916666f..1c18d74 100644 --- a/tests/panic_test.rs +++ b/tests/panic_test.rs @@ -5,8 +5,14 @@ use core::panic::PanicInfo; use dendrobates_tinctoreus_azureus::{exit_qemu, QemuExitCode}; use polling_serial::{serial_print, serial_println}; -#[no_mangle] -pub extern "C" fn _start() -> ! { +use bootloader::{entry_point, BootInfo}; + +entry_point!(test_kernel_main); + +/// Entry point for `cargo xtest` + +fn test_kernel_main(_boot_info: &'static BootInfo) -> ! { + dendrobates_tinctoreus_azureus::init(); should_fail(); serial_println!("[test did not panic]"); exit_qemu(QemuExitCode::Failed); diff --git a/tests/sse_interrupt_test.rs b/tests/sse_interrupt_test.rs index 6e64c29..155f716 100644 --- a/tests/sse_interrupt_test.rs +++ b/tests/sse_interrupt_test.rs @@ -20,8 +20,14 @@ use vga_buffer::{print, println}; use volatile::Volatile; use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame}; -#[no_mangle] // don't mangle the name of this function -pub extern "C" fn _start() -> ! { +use bootloader::{entry_point, BootInfo}; + +entry_point!(test_kernel_main); + +/// Entry point for `cargo xtest` + +fn test_kernel_main(_boot_info: &'static BootInfo) -> ! { + dendrobates_tinctoreus_azureus::init(); test_main(); loop {} diff --git a/tests/stack_overflow.rs b/tests/stack_overflow.rs index bc430b1..3815c14 100644 --- a/tests/stack_overflow.rs +++ b/tests/stack_overflow.rs @@ -9,8 +9,13 @@ use core::panic::PanicInfo; use dendrobates_tinctoreus_azureus::{exit_qemu, QemuExitCode}; use polling_serial::{serial_print, serial_println}; -#[no_mangle] -pub extern "C" fn _start() -> ! { +use bootloader::{entry_point, BootInfo}; + +entry_point!(test_kernel_main); + +/// Entry point for `cargo xtest` + +fn test_kernel_main(_boot_info: &'static BootInfo) -> ! { serial_print!("stack_overflow... "); dendrobates_tinctoreus_azureus::gdt::init();