2022-01-06 16:21:23 +01:00
|
|
|
mod tests;
|
|
|
|
mod utils;
|
|
|
|
|
|
|
|
use oci_spec::runtime::Spec;
|
2023-01-24 07:58:07 +01:00
|
|
|
use std::env;
|
2023-02-01 09:01:02 +01:00
|
|
|
use std::path::PathBuf;
|
2022-12-19 09:45:33 +01:00
|
|
|
|
2022-01-08 10:31:26 +01:00
|
|
|
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) => {
|
2023-02-12 12:08:03 +01:00
|
|
|
eprintln!("Error in loading spec, {e:?}");
|
2022-01-06 16:21:23 +01:00
|
|
|
std::process::exit(66);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-23 13:28:19 +02:00
|
|
|
////////// ANCHOR: example_runtimetest_main
|
2022-01-06 12:00:19 +01:00
|
|
|
fn main() {
|
2022-01-06 16:21:23 +01:00
|
|
|
let spec = get_spec();
|
2023-01-24 07:58:07 +01:00
|
|
|
let args: Vec<String> = env::args().collect();
|
|
|
|
let execute_test = match args.get(1) {
|
|
|
|
Some(execute_test) => execute_test.to_string(),
|
2023-01-24 08:57:23 +01:00
|
|
|
None => return eprintln!("error due to execute test name not found"),
|
2022-12-19 09:45:33 +01:00
|
|
|
};
|
2023-02-01 09:01:02 +01:00
|
|
|
|
2023-01-24 07:58:07 +01:00
|
|
|
match &*execute_test {
|
2023-09-23 13:28:19 +02:00
|
|
|
"hello_world" => tests::hello_world(&spec),
|
|
|
|
////////// ANCHOR_END: example_runtimetest_main
|
2023-01-24 07:58:07 +01:00
|
|
|
"readonly_paths" => tests::validate_readonly_paths(&spec),
|
|
|
|
"set_host_name" => tests::validate_hostname(&spec),
|
|
|
|
"mounts_recursive" => tests::validate_mounts_recursive(&spec),
|
2023-02-12 12:08:03 +01:00
|
|
|
_ => eprintln!("error due to unexpected execute test name: {execute_test}"),
|
2023-01-24 07:58:07 +01:00
|
|
|
}
|
2022-01-06 12:00:19 +01:00
|
|
|
}
|