Crates.io | bare-test |
lib.rs | bare-test |
version | |
source | src |
created_at | 2024-10-31 08:53:21.419698 |
updated_at | 2024-12-10 05:45:23.500109 |
description | A test framework for bare metal. |
homepage | |
repository | https://github.com/qclic/sparreal-os/tree/main/crates/bare-test |
max_upload_size | |
id | 1429816 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A test framework for testing the bare metal.
Install ostool
.
cargo install ostool
setup .cargo/config.toml
[target.'cfg(all(target_os = "none"))']
runner = "ostool cargo-test"
[build]
target = "aarch64-unknown-none"
setup cargo.toml
.
[dev-dependencies]
bare-test = "0.0.1"
[build-dependencies]
sparreal-macros = "0.0.1"
setup build.rs
.
fn main() {
sparreal_macros::build_test_setup!();
}
new tests
dir and add tests.rs
.
#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(bare_test::test_runner)]
#![reexport_test_harness_main = "test_main"]
extern crate bare_test;
#[bare_test::entry]
fn main() {
test_main();
}
use bare_test::println;
#[test_case]
fn it_not_works() {
println!("test2... ");
assert_eq!(1, 2);
}
#[test_case]
fn it_works1() {
println!("test1... ");
assert_eq!(1, 1);
}
#[test_case]
fn test_uart(){
// map uart data register for using.
let uart_data_reg = iomap(0x9000000.into(), 0x1000);
// write to uart, then it will be print to the screen.
unsafe{
uart_data_reg.write_volatile(b'A');
uart_data_reg.write_volatile(b'\n');
}
println!("uart test passed!");
}
run cargo test --test tests -- --show-output
.