1
0
Fork 0
mirror of https://github.com/containers/youki synced 2024-05-10 01:26:14 +02:00
youki/tests/contest/runtimetest/src/main.rs
Toru Komatsu 464344923f
Name the test tools `contest` (#2486)
* Name the test tools `contest`

Signed-off-by: utam0k <k0ma@utam0k.jp>

* Address the feedbacks

Signed-off-by: utam0k <k0ma@utam0k.jp>

* Fix a build error

Signed-off-by: utam0k <k0ma@utam0k.jp>

* Fix a workflow

Signed-off-by: utam0k <k0ma@utam0k.jp>

* Address the feedbacks

Signed-off-by: utam0k <k0ma@utam0k.jp>

---------

Signed-off-by: utam0k <k0ma@utam0k.jp>
2024-01-12 14:28:47 +05:30

41 lines
1.2 KiB
Rust

mod tests;
mod utils;
use oci_spec::runtime::Spec;
use std::env;
use std::path::PathBuf;
const SPEC_PATH: &str = "/config.json";
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:?}");
std::process::exit(66);
}
}
}
////////// ANCHOR: example_runtimetest_main
fn main() {
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),
"seccomp" => tests::validate_seccomp(&spec),
"sysctl" => tests::validate_sysctl(&spec),
_ => eprintln!("error due to unexpected execute test name: {execute_test}"),
}
}