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());
|
.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]");
|
||||||
|
}
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -6,26 +6,26 @@
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use alloc::string::ToString;
|
|
||||||
use bootloader::{entry_point, BootInfo};
|
use bootloader::{entry_point, BootInfo};
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
use xe_os::println;
|
use alloc::string::ToString;
|
||||||
|
use xe_os::{clock, init, println, wasm};
|
||||||
|
|
||||||
entry_point!(kernel_main);
|
entry_point!(kernel_main);
|
||||||
|
|
||||||
fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||||
xe_os::init(&boot_info);
|
init(&boot_info);
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
test_main();
|
test_main();
|
||||||
|
|
||||||
// Read the rtc date time using this year
|
// Read the rtc date time using this year
|
||||||
let now = xe_os::clock::current_time();
|
let now = clock::current_time();
|
||||||
println!("{}", now.to_string());
|
println!("now: {}", now.to_string());
|
||||||
|
|
||||||
println!("Running WASM:");
|
println!("Running WASM:");
|
||||||
|
|
||||||
xe_os::wasm::run();
|
wasm::run();
|
||||||
println!("[ ] success");
|
println!("[ ] success");
|
||||||
|
|
||||||
xe_os::hlt_loop();
|
xe_os::hlt_loop();
|
||||||
|
|
Loading…
Reference in New Issue