38 lines
1,013 B
Rust
38 lines
1,013 B
Rust
|
pub use ktest_macro::ktest;
|
||
|
use log::debug;
|
||
|
|
||
|
extern "C" {
|
||
|
static __ktest_start: fn();
|
||
|
static __ktest_end: fn();
|
||
|
}
|
||
|
|
||
|
// TODO: Get test_fn linker name (may require no_mangle in macro)
|
||
|
// More info on tests (run the rest even if panic)
|
||
|
// Implement ktest for arm and riscv (Later problems, see below)
|
||
|
// Allow for arch specific tests (Leave for now)
|
||
|
// Allow for ktest test name attr
|
||
|
// Usefull message at the end of testing
|
||
|
pub fn test_main() {
|
||
|
unsafe {
|
||
|
let mut current_test = &__ktest_start as *const fn();
|
||
|
let mut current = 1;
|
||
|
let test_end = &__ktest_end as *const fn();
|
||
|
|
||
|
while current_test < test_end {
|
||
|
let test_fn = *current_test;
|
||
|
|
||
|
debug!("Running test {}", current);
|
||
|
|
||
|
test_fn();
|
||
|
debug!("Test {} passed", current);
|
||
|
|
||
|
current_test = current_test.add(1);
|
||
|
current += 1;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[ktest]
|
||
|
pub fn trivial_assertion() {
|
||
|
assert_eq!(1, 1);
|
||
|
}
|