1
0
Fork 0
mirror of https://github.com/containers/youki synced 2024-06-07 15:26:14 +02:00
youki/tests/runtimetest/src/main.rs

39 lines
1.1 KiB
Rust
Raw Normal View History

2022-01-06 16:21:23 +01:00
mod tests;
mod utils;
use oci_spec::runtime::Spec;
use std::env;
use std::path::PathBuf;
const SPEC_PATH: &str = "/config.json";
2022-01-06 16:21:23 +01:00
fn get_spec() -> Spec {
let path = PathBuf::from(SPEC_PATH);
match Spec::load(path) {
Ok(spec) => spec,
Err(e) => {
eprintln!("Error in loading spec, {e:?}");
2022-01-06 16:21:23 +01:00
std::process::exit(66);
}
}
}
////////// ANCHOR: example_runtimetest_main
fn main() {
2022-01-06 16:21:23 +01:00
let spec = get_spec();
let args: Vec<String> = env::args().collect();
let execute_test = match args.get(1) {
Some(execute_test) => execute_test.to_string(),
None => return eprintln!("error due to execute test name not found"),
};
match &*execute_test {
"hello_world" => tests::hello_world(&spec),
////////// ANCHOR_END: example_runtimetest_main
"readonly_paths" => tests::validate_readonly_paths(&spec),
"set_host_name" => tests::validate_hostname(&spec),
"mounts_recursive" => tests::validate_mounts_recursive(&spec),
_ => eprintln!("error due to unexpected execute test name: {execute_test}"),
}
}