From 39443666e7e4d41d9feb90af295ca2c4b297997f Mon Sep 17 00:00:00 2001 From: ami-chuu Date: Mon, 30 Mar 2026 02:42:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?tests=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/basic_boot.rs | 29 +++++++++++++++++++++++++++++ tests/should_panic.rs | 25 +++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/basic_boot.rs create mode 100644 tests/should_panic.rs diff --git a/tests/basic_boot.rs b/tests/basic_boot.rs new file mode 100644 index 0000000..4c4ea23 --- /dev/null +++ b/tests/basic_boot.rs @@ -0,0 +1,29 @@ +#![no_std] +#![no_main] +#![feature(custom_test_frameworks)] +#![test_runner(amix::test_runner)] +#![reexport_test_harness_main = "test_main"] + +use amix::println; +use core::panic::PanicInfo; + +#[unsafe(no_mangle)] // don't mangle the name of this function +pub extern "C" fn _start() -> ! { + test_main(); + + loop {} +} + +fn test_runner(tests: &[&dyn Fn()]) { + unimplemented!(); +} + +#[panic_handler] +fn panic(info: &PanicInfo) -> ! { + amix::test_panic_handler(info) +} + +#[test_case] +fn test_println() { + println!("test_println output"); +} diff --git a/tests/should_panic.rs b/tests/should_panic.rs new file mode 100644 index 0000000..5b358e4 --- /dev/null +++ b/tests/should_panic.rs @@ -0,0 +1,25 @@ +#![no_std] +#![no_main] + +use amix::{exit_qemu, serial_print, serial_println, QemuExitCode}; +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 {} +}