test clock, simplify
This commit is contained in:
parent
9014c1f167
commit
deb45d5266
14
src/clock.rs
14
src/clock.rs
|
@ -18,3 +18,17 @@ pub fn current_time() -> DateTime<Utc> {
|
|||
)
|
||||
.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]");
|
||||
}
|
||||
|
|
14
src/main.rs
14
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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue