Implement OSDK functionalities and opt-in OSDK for asterinas

This commit is contained in:
Zhang Junyang
2024-02-21 16:58:40 +08:00
committed by Tate, Hongliang Tian
parent bc9bce9dea
commit f97d0f1260
103 changed files with 1663 additions and 1295 deletions

View File

@ -21,8 +21,8 @@
//! module, e.g.:
//!
//! ```rust
//! use ktest::{ktest, if_cfg_ktest};
//! #[if_cfg_ktest]
//! use ktest::ktest;
//! #[cfg(ktest)]
//! mod test {
//! #[ktest]
//! fn trivial_assertion() {
@ -97,7 +97,7 @@ extern crate alloc;
use alloc::{boxed::Box, string::String};
use core::result::Result;
pub use ktest_proc_macro::{if_cfg_ktest, ktest};
pub use ktest_proc_macro::ktest;
#[derive(Clone, Debug)]
pub struct PanicInfo {

View File

@ -3,7 +3,7 @@
//! Test runner enabling control over the tests.
//!
use alloc::{string::String, vec::Vec};
use alloc::{string::String, vec::Vec, collections::BTreeSet};
use core::format_args;
use owo_colors::OwoColorize;
@ -35,7 +35,8 @@ pub enum KtestResult {
pub fn run_ktests<PrintFn, PathsIter>(
print: &PrintFn,
catch_unwind: &CatchUnwindImpl,
whitelist: Option<PathsIter>,
test_whitelist: Option<PathsIter>,
crate_whitelist: Option<&[&str]>,
) -> KtestResult
where
PrintFn: Fn(core::fmt::Arguments),
@ -48,7 +49,7 @@ where
}
let whitelist_trie =
whitelist.map(|paths| SuffixTrie::from_paths(paths.map(|p| KtestPath::from(&p))));
test_whitelist.map(|paths| SuffixTrie::from_paths(paths.map(|p| KtestPath::from(&p))));
let tree = KtestTree::from_iter(KtestIter::new());
print!(
@ -56,7 +57,15 @@ where
tree.nr_tot_tests(),
tree.nr_tot_crates()
);
let crate_set =
crate_whitelist.map(|crates| crates.iter().copied().collect::<BTreeSet<&str>>());
for crate_ in tree.iter() {
if let Some(crate_set) = &crate_set {
if !crate_set.contains(crate_.name()) {
print!("\n[ktest runner] skipping crate \"{}\".\n", crate_.name());
continue;
}
}
match run_crate_ktests(crate_, print, catch_unwind, &whitelist_trie) {
KtestResult::Ok => {}
KtestResult::Failed => return KtestResult::Failed,