add base test functiuon
This commit is contained in:
parent
82f4bd2b09
commit
584aa7b38d
3 changed files with 22 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
[unstable]
|
[unstable]
|
||||||
build-std-features = ["compiler-builtins-mem"]
|
build-std-features = ["compiler-builtins-mem"]
|
||||||
build-std = ["core", "compiler_builtins"]
|
build-std = ["core", "compiler_builtins"]
|
||||||
|
panic-abort-tests = true
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
target = ["x86_64-donald.json"]
|
target = ["x86_64-donald.json"]
|
||||||
|
|
|
@ -4,7 +4,7 @@ version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
panic = "abort"
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|
21
src/main.rs
21
src/main.rs
|
@ -1,6 +1,17 @@
|
||||||
#![allow()]
|
#![allow()]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
#![feature(custom_test_frameworks)]
|
||||||
|
#![test_runner(crate::test_runner)]
|
||||||
|
#![reexport_test_harness_main = "test_main"]
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub fn test_runner(tests: &[&dyn Fn()]) {
|
||||||
|
println!("Running {} tests", tests.len());
|
||||||
|
for test in tests {
|
||||||
|
test();
|
||||||
|
}
|
||||||
|
}
|
||||||
mod vga_buffer;
|
mod vga_buffer;
|
||||||
|
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
@ -14,7 +25,15 @@ fn panic(info: &PanicInfo) -> ! {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn _start() -> ! {
|
pub extern "C" fn _start() -> ! {
|
||||||
println!("Hello World!");
|
println!("Hello World!");
|
||||||
panic!("Nothing to do.");
|
#[cfg(test)]
|
||||||
|
test_main();
|
||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test_case]
|
||||||
|
fn trivial_assertion() {
|
||||||
|
print!("trivial assertion... ");
|
||||||
|
assert_eq!(1, 1);
|
||||||
|
println!("[ok]");
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue