From deb45d5266acbe694a3d7eebe06bb1ca1587a6ba Mon Sep 17 00:00:00 2001 From: Within Date: Thu, 24 Oct 2019 11:34:10 -0400 Subject: [PATCH] test clock, simplify --- src/clock.rs | 14 ++++++++++++++ src/main.rs | 14 +++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/clock.rs b/src/clock.rs index d4de373..3ce86b9 100644 --- a/src/clock.rs +++ b/src/clock.rs @@ -18,3 +18,17 @@ pub fn current_time() -> DateTime { ) .and_hms(rtc.hour.into(), rtc.minute.into(), rtc.second.into()); } + +#[cfg(test)] +use crate::{serial_print, serial_println, println}; + +#[test_case] +fn test_current_time() { + serial_print!("current time... "); + let now = current_time(); + println!("{:?}", now); + + assert_ne!(now.month(), 0); + + serial_println!("[ok]"); +} diff --git a/src/main.rs b/src/main.rs index dd2984b..3b57f10 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,28 +6,28 @@ extern crate alloc; -use alloc::string::ToString; use bootloader::{entry_point, BootInfo}; use core::panic::PanicInfo; -use xe_os::println; +use alloc::string::ToString; +use xe_os::{clock, init, println, wasm}; entry_point!(kernel_main); fn kernel_main(boot_info: &'static BootInfo) -> ! { - xe_os::init(&boot_info); + init(&boot_info); #[cfg(test)] test_main(); // Read the rtc date time using this year - let now = xe_os::clock::current_time(); - println!("{}", now.to_string()); + let now = clock::current_time(); + println!("now: {}", now.to_string()); println!("Running WASM:"); - xe_os::wasm::run(); + wasm::run(); println!("[ ] success"); - + xe_os::hlt_loop(); }