50 lines
970 B
Rust
50 lines
970 B
Rust
#![no_std]
|
|
#![no_main]
|
|
#![feature(custom_test_frameworks)]
|
|
#![test_runner(xe_os::test_runner)]
|
|
#![reexport_test_harness_main = "test_main"]
|
|
|
|
extern crate alloc;
|
|
|
|
use bootloader::{entry_point, BootInfo};
|
|
use core::panic::PanicInfo;
|
|
|
|
entry_point!(main);
|
|
|
|
fn main(boot_info: &'static BootInfo) -> ! {
|
|
xe_os::init(boot_info);
|
|
|
|
test_main();
|
|
loop {}
|
|
}
|
|
|
|
#[panic_handler]
|
|
fn panic(info: &PanicInfo) -> ! {
|
|
xe_os::test_panic_handler(info)
|
|
}
|
|
|
|
use xe_os::{serial_print, serial_println};
|
|
use alloc::boxed::Box;
|
|
|
|
#[test_case]
|
|
fn simple_allocation() {
|
|
serial_print!("simple_allocation... ");
|
|
let heap_value = Box::new(41);
|
|
assert_eq!(*heap_value, 41);
|
|
serial_println!("[ok]");
|
|
}
|
|
|
|
use alloc::vec::Vec;
|
|
|
|
#[test_case]
|
|
fn large_vec() {
|
|
serial_print!("large_vec... ");
|
|
let n = 1000;
|
|
let mut vec = Vec::new();
|
|
for i in 0..n {
|
|
vec.push(i);
|
|
}
|
|
assert_eq!(vec.iter().sum::<u64>(), (n - 1) * n / 2);
|
|
serial_println!("[ok]");
|
|
}
|