diff --git a/src/lib.rs b/src/lib.rs index 3d1f222..f8d9d50 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,17 @@ use core::panic::PanicInfo; + + +#[cfg(test)] +use vga_buffer::print; + +#[cfg(test)] +use polling_serial::serial_print; + use polling_serial::serial_println; + + use vga_buffer::println; use x86_64::instructions::bochs_breakpoint; diff --git a/src/main.rs b/src/main.rs index cf7bf29..94f4ca7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,16 +8,25 @@ #![reexport_test_harness_main = "test_main"] use polling_serial::serial_println; -use vga_buffer::{println, set_colors, Color, ForegroundColor}; + +#[cfg(test)] +use polling_serial::serial_print; + +use vga_buffer::println; use core::panic::PanicInfo; use vga_buffer; // required for custom panic handler -use dendrobates_tinctoreus_azureus::hlt_loop; use x86_64; use bootloader::{entry_point, BootInfo}; +#[cfg(not(test))] +use dendrobates_tinctoreus_azureus::hlt_loop; + +#[cfg(not(test))] +use vga_buffer::{set_colors, Color, ForegroundColor}; + // Custom panic handler, required for freestanding program #[cfg(not(test))] #[panic_handler] @@ -32,7 +41,7 @@ fn panic(info: &PanicInfo) -> ! { entry_point!(kernel_main); // Kernel entry point -fn kernel_main(boot_info: &'static BootInfo) -> ! { +fn kernel_main(_boot_info: &'static BootInfo) -> ! { // TODO: Take care of cpuid stuff and set-up all floating point exetnsions // TODO: We may also need to enable debug registers ? @@ -103,7 +112,7 @@ fn float_test() { rf, vf ); - if (rf == vf) { + if rf == vf { serial_println!("[ok]"); } else { serial_println!("[fail]"); @@ -115,7 +124,7 @@ fn float_test() { rd, vd ); - if (rd == vd) { + if rd == vd { serial_println!("[ok]"); } else { serial_println!("[fail]"); @@ -124,12 +133,3 @@ fn float_test() { assert_eq!(rd, vd); serial_println!("Testing float computations... [ok]"); } - -//#[test_case] -//fn failing_assertion() { -// print!("trivial assertion... "); -// serial_print!("trivial assertion... "); -// assert_eq!(1, 1); -// println!("[ok]"); -// serial_println!("[ok]"); -//} diff --git a/tests/basic_boot.rs b/tests/basic_boot.rs index 2aec38b..dcc1864 100644 --- a/tests/basic_boot.rs +++ b/tests/basic_boot.rs @@ -6,7 +6,7 @@ use core::panic::PanicInfo; use polling_serial::{serial_print, serial_println}; -use vga_buffer::{print, println}; +use vga_buffer::println; use bootloader::{entry_point, BootInfo}; diff --git a/tests/panic_test.rs b/tests/panic_test.rs index 1c18d74..1bcf2fa 100644 --- a/tests/panic_test.rs +++ b/tests/panic_test.rs @@ -16,7 +16,6 @@ fn test_kernel_main(_boot_info: &'static BootInfo) -> ! { should_fail(); serial_println!("[test did not panic]"); exit_qemu(QemuExitCode::Failed); - loop {} } fn should_fail() { @@ -28,5 +27,5 @@ fn should_fail() { fn panic(_info: &PanicInfo) -> ! { serial_println!("[ok]"); exit_qemu(QemuExitCode::Success); - loop {} + } diff --git a/tests/sse_interrupt_test.rs b/tests/sse_interrupt_test.rs index 155f716..026c52d 100644 --- a/tests/sse_interrupt_test.rs +++ b/tests/sse_interrupt_test.rs @@ -16,7 +16,7 @@ use core::panic::PanicInfo; use lazy_static::lazy_static; use polling_serial::{serial_print, serial_println}; -use vga_buffer::{print, println}; +use vga_buffer::{println}; use volatile::Volatile; use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame}; @@ -87,7 +87,7 @@ fn test_intr() { rf, vf ); - if (rf == vf) { + if rf == vf { serial_println!("[ok]"); } else { serial_println!("[fail]"); @@ -99,7 +99,7 @@ fn test_intr() { rd, vd ); - if (rd == vd) { + if rd == vd { serial_println!("[ok]"); } else { serial_println!("[fail]");