aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatasha Moongrave <natasha@256phi.eu>2026-02-17 20:49:57 +0100
committerNatasha Moongrave <natasha@256phi.eu>2026-02-17 20:49:57 +0100
commit4cbeab6048ed2e8a140eecc403d3c85316aa97ea (patch)
tree082f8793ee0822fa1001dc839ff93f7e56dcb531
parent85d391fb0d81186aac9917348c2fa400b789742b (diff)
added tests
-rw-r--r--StrixKernel/tests/basic_boot.rs25
-rw-r--r--StrixKernel/tests/should_panic.rs25
2 files changed, 50 insertions, 0 deletions
diff --git a/StrixKernel/tests/basic_boot.rs b/StrixKernel/tests/basic_boot.rs
new file mode 100644
index 0000000..e29dcea
--- /dev/null
+++ b/StrixKernel/tests/basic_boot.rs
@@ -0,0 +1,25 @@
+#![no_std]
+#![no_main]
+#![feature(custom_test_frameworks)]
+#![test_runner(strix_os::test_runner)]
+#![reexport_test_harness_main = "test_main"]
+
+use strix_os::println;
+use core::panic::PanicInfo;
+
+#[unsafe(no_mangle)] // don't mangle the name of this function
+pub extern "C" fn _start() -> ! {
+ test_main();
+
+ loop {}
+}
+
+#[panic_handler]
+fn panic(info: &PanicInfo) -> ! {
+ strix_os::test_panic_handler(info)
+}
+
+#[test_case]
+fn test_println() {
+ println!("test_println output");
+} \ No newline at end of file
diff --git a/StrixKernel/tests/should_panic.rs b/StrixKernel/tests/should_panic.rs
new file mode 100644
index 0000000..3cbe0a8
--- /dev/null
+++ b/StrixKernel/tests/should_panic.rs
@@ -0,0 +1,25 @@
+#![no_std]
+#![no_main]
+
+use strix_os::{QemuExitCode, exit_qemu, serial_print, serial_println};
+use core::panic::PanicInfo;
+
+#[unsafe(no_mangle)]
+pub extern "C" fn _start() -> ! {
+ should_fail();
+ serial_println!("[test did not panic]");
+ exit_qemu(QemuExitCode::Failed);
+ loop {}
+}
+
+fn should_fail() {
+ serial_print!("should_panic::should_fail...\t");
+ assert_eq!(0, 1);
+}
+
+#[panic_handler]
+fn panic(_info: &PanicInfo) -> ! {
+ serial_println!("[ok]");
+ exit_qemu(QemuExitCode::Success);
+ loop {}
+} \ No newline at end of file