aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatasha Moongrave <natasha@256phi.eu>2026-03-30 12:31:48 +0200
committerNatasha Moongrave <natasha@256phi.eu>2026-03-30 12:31:48 +0200
commita9f7c3a72e7beb802365ab12ce2032dd023e2c28 (patch)
tree983f29cec5845b4450714c135af060aaed43f9ef
parentd46afa378b20fca2c68b47a2e5ab5885bd5f90c5 (diff)
added serial output integration tests
-rw-r--r--StrixKernel/tests/serial_output.rs101
1 files changed, 101 insertions, 0 deletions
diff --git a/StrixKernel/tests/serial_output.rs b/StrixKernel/tests/serial_output.rs
new file mode 100644
index 0000000..1696cc2
--- /dev/null
+++ b/StrixKernel/tests/serial_output.rs
@@ -0,0 +1,101 @@
+//! # Serial Output Integration Test
+//!
+//! This integration test verifies that serial port communication works correctly
+//! in a real boot context.
+//!
+//! ## Purpose
+//!
+//! Serial output is critical for kernel development because:
+//! - Test results are reported via serial port
+//! - Debug output goes through serial
+//! - It works before VGA initialization
+//!
+//! This test verifies:
+//! - `serial_print!` macro works correctly
+//! - `serial_println!` macro works correctly
+//! - Format arguments are properly handled
+//! - The UART 16550 serial port is correctly initialized
+//!
+//! ## Running This Test
+//!
+//! ```bash
+//! cargo test --test serial_output
+//! ```
+
+#![no_std]
+#![no_main]
+#![feature(custom_test_frameworks)]
+#![test_runner(strix_os::test_runner)]
+#![reexport_test_harness_main = "test_main"]
+
+use core::panic::PanicInfo;
+use strix_os::{serial_print, serial_println};
+
+#[unsafe(no_mangle)]
+pub extern "C" fn _start() -> ! {
+ test_main();
+
+ loop {}
+}
+
+#[panic_handler]
+fn panic(info: &PanicInfo) -> ! {
+ strix_os::test_panic_handler(info)
+}
+
+/// Tests that `serial_println!` works with no arguments.
+///
+/// This is the simplest case - just outputting a newline.
+#[test_case]
+fn test_serial_println_empty() {
+ serial_println!();
+}
+
+/// Tests that `serial_println!` works with a simple string.
+#[test_case]
+fn test_serial_println_simple() {
+ serial_println!("test_serial_println_simple output");
+}
+
+/// Tests that `serial_println!` correctly formats arguments.
+///
+/// This verifies that the format_args! macro integration works properly.
+#[test_case]
+fn test_serial_println_formatting() {
+ let value = 42;
+ serial_println!("Formatted output: value = {}, hex = {:#x}", value, value);
+}
+
+/// Tests that `serial_print!` works without a newline.
+#[test_case]
+fn test_serial_print_no_newline() {
+ serial_print!("Part 1... ");
+ serial_print!("Part 2... ");
+ serial_println!("Done!");
+}
+
+/// Tests serial output with various data types.
+#[test_case]
+fn test_serial_various_types() {
+ let unsigned: u64 = 12345678901234;
+ let signed: i32 = -42;
+ let boolean = true;
+ let character = 'X';
+
+ serial_println!("u64: {}", unsigned);
+ serial_println!("i32: {}", signed);
+ serial_println!("bool: {}", boolean);
+ serial_println!("char: {}", character);
+}
+
+/// Tests that many serial writes in sequence work correctly.
+///
+/// This stress-tests the serial port to ensure it handles rapid writes.
+#[test_case]
+fn test_serial_many_writes() {
+ for i in 0..100 {
+ serial_print!("{} ", i);
+ }
+ serial_println!();
+ serial_println!("Completed 100 sequential writes");
+}