Merge branch 'post-05' into post-06

This commit is contained in:
Philipp Oppermann
2020-06-08 11:57:12 +02:00
6 changed files with 23 additions and 22 deletions

View File

@@ -16,11 +16,25 @@ pub fn init() {
gdt::init();
interrupts::init_idt();
}
pub trait Testable {
fn run(&self) -> ();
}
pub fn test_runner(tests: &[&dyn Fn()]) {
impl<T> Testable for T
where
T: Fn(),
{
fn run(&self) {
serial_print!("{}...\t", core::any::type_name::<T>());
self();
serial_println!("[ok]");
}
}
pub fn test_runner(tests: &[&dyn Testable]) {
serial_println!("Running {} tests", tests.len());
for test in tests {
test();
test.run();
}
exit_qemu(QemuExitCode::Success);
}