mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-02 13:44:33 +00:00
kata-ctl: add code for framework for arch
Add framework for different architectures for check. In the existing kata-runtime check, the network checks do not appear to be architecture-specific while the kernel module, cpu, and kvm checks do have separate implementations for different architectures. Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
This commit is contained in:
parent
303fc8b118
commit
8e7bb8521c
15
src/tools/kata-ctl/src/arch/aarch64/mod.rs
Normal file
15
src/tools/kata-ctl/src/arch/aarch64/mod.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (c) 2022 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
pub use arch_specific::*;
|
||||
|
||||
mod arch_specific {
|
||||
use anyhow::Result;
|
||||
|
||||
pub fn check() -> Result<()> {
|
||||
unimplemented!("Check not implemented in aarch64")
|
||||
}
|
||||
}
|
42
src/tools/kata-ctl/src/arch/mod.rs
Normal file
42
src/tools/kata-ctl/src/arch/mod.rs
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2022 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
use anyhow::{Result};
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
pub mod aarch64;
|
||||
|
||||
#[cfg(target_arch = "powerpc64le")]
|
||||
pub mod powerpc64le;
|
||||
|
||||
#[cfg(target_arch = "s390x")]
|
||||
pub mod s390x;
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub mod x86_64;
|
||||
|
||||
pub fn check(global_args: clap::ArgMatches) -> Result<()> {
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
let result = aarch64::check();
|
||||
|
||||
#[cfg(target_arch = "powerpc64le")]
|
||||
let result = powerpc64le::check();
|
||||
|
||||
#[cfg(target_arch = "s390x")]
|
||||
let result = s390x::check();
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
let result = x86_64::check(global_args);
|
||||
|
||||
#[cfg(not(any(
|
||||
target_arch = "aarch64",
|
||||
target_arch = "powerpc64le",
|
||||
target_arch = "s390x",
|
||||
target_arch = "x86_64"
|
||||
)))]
|
||||
panic!("unknown architecture");
|
||||
|
||||
result
|
||||
}
|
15
src/tools/kata-ctl/src/arch/powerpc64le/mod.rs
Normal file
15
src/tools/kata-ctl/src/arch/powerpc64le/mod.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (c) 2022 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#[cfg(target_arch = "powerpc64le")]
|
||||
pub use arch_specific::*;
|
||||
|
||||
mod arch_specific {
|
||||
use anyhow::Result;
|
||||
|
||||
pub fn check() -> Result<()> {
|
||||
unimplemented!("Check not implemented in powerpc64le");
|
||||
}
|
||||
}
|
15
src/tools/kata-ctl/src/arch/s390x/mod.rs
Normal file
15
src/tools/kata-ctl/src/arch/s390x/mod.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (c) 2022 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#[cfg(target_arch = "s390x")]
|
||||
pub use arch_specific::*;
|
||||
|
||||
mod arch_specific {
|
||||
use anyhow::Result;
|
||||
|
||||
pub fn check() -> Result<()> {
|
||||
unimplemented!("Check not implemented in s390x");
|
||||
}
|
||||
}
|
17
src/tools/kata-ctl/src/arch/x86_64/mod.rs
Normal file
17
src/tools/kata-ctl/src/arch/x86_64/mod.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (c) 2022 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub use arch_specific::*;
|
||||
|
||||
mod arch_specific {
|
||||
use anyhow::Result;
|
||||
|
||||
pub fn check(_global_args: clap::ArgMatches) -> Result<()> {
|
||||
println!("INFO: check: x86_64");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
12
src/tools/kata-ctl/src/check.rs
Normal file
12
src/tools/kata-ctl/src/check.rs
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) 2022 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
// Contains checks that are not architecture-specific
|
||||
|
||||
use anyhow::{Result};
|
||||
|
||||
pub fn run_network_checks() -> Result<()> {
|
||||
unimplemented!("Tests using network checks not implemented");
|
||||
}
|
@ -9,6 +9,8 @@ use std::process::exit;
|
||||
|
||||
mod utils;
|
||||
mod version;
|
||||
mod arch;
|
||||
mod check;
|
||||
|
||||
const DESCRIPTION_TEXT: &str = r#"DESCRIPTION:
|
||||
kata-ctl description placeholder."#;
|
||||
@ -17,6 +19,25 @@ const ABOUT_TEXT: &str = "Kata Containers control tool";
|
||||
|
||||
const NAME: &str = "kata-ctl";
|
||||
|
||||
fn run_checks(global_args: clap::ArgMatches) -> Result<()> {
|
||||
let args = global_args
|
||||
.subcommand_matches("check")
|
||||
.ok_or_else(|| anyhow!("BUG: missing sub-command arguments"))?;
|
||||
|
||||
let no_network_check = args.is_present("no-network-checks");
|
||||
|
||||
// run architecture-agnostic tests
|
||||
if !no_network_check {
|
||||
// run code that uses network checks
|
||||
let _network_checks = check::run_network_checks();
|
||||
}
|
||||
|
||||
// run architecture-specific tests
|
||||
let _all_checks = arch::check(global_args);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn real_main() -> Result<()> {
|
||||
let name = crate_name!();
|
||||
let version = version::get();
|
||||
@ -28,15 +49,11 @@ fn real_main() -> Result<()> {
|
||||
.subcommand(
|
||||
SubCommand::with_name("check")
|
||||
.about("tests if system can run Kata Containers")
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("command-example")
|
||||
.about("(remove when other subcommands have sufficient detail)")
|
||||
.arg(
|
||||
Arg::with_name("arg-example-1")
|
||||
.long("arg-example-1")
|
||||
.help("arg example for command-example")
|
||||
.takes_value(true)
|
||||
Arg::with_name("no-network-checks")
|
||||
.long("no-network-checks")
|
||||
.help("run check with no network checks")
|
||||
.takes_value(false)
|
||||
)
|
||||
)
|
||||
.subcommand(
|
||||
@ -80,40 +97,39 @@ fn real_main() -> Result<()> {
|
||||
.ok_or_else(|| anyhow!("need sub-command"))?;
|
||||
|
||||
match subcmd {
|
||||
"command-example" => {
|
||||
println!("{}", utils::command_example(args));
|
||||
Ok(())
|
||||
}
|
||||
"check" => {
|
||||
println!("Not implemented");
|
||||
match run_checks(args) {
|
||||
Ok(_result) => println!("check may not be fully implemented"),
|
||||
Err(err) => println!("{}", err),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
"direct-volume" => {
|
||||
println!("Not implemented");
|
||||
unimplemented!("Not implemented");
|
||||
Ok(())
|
||||
}
|
||||
"env" => {
|
||||
println!("Not implemented");
|
||||
unimplemented!("Not implemented");
|
||||
Ok(())
|
||||
}
|
||||
"exec" => {
|
||||
println!("Not implemented");
|
||||
unimplemented!("Not implemented");
|
||||
Ok(())
|
||||
}
|
||||
"factory" => {
|
||||
println!("Not implemented");
|
||||
unimplemented!("Not implemented");
|
||||
Ok(())
|
||||
}
|
||||
"help" => {
|
||||
println!("Not implemented");
|
||||
unimplemented!("Not implemented");
|
||||
Ok(())
|
||||
}
|
||||
"iptables" => {
|
||||
println!("Not implemented");
|
||||
unimplemented!("Not implemented");
|
||||
Ok(())
|
||||
}
|
||||
"metrics" => {
|
||||
println!("Not implemented");
|
||||
unimplemented!("Not implemented");
|
||||
Ok(())
|
||||
}
|
||||
"version" => {
|
||||
|
@ -2,7 +2,3 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
pub fn command_example(_global_args: clap::ArgMatches) -> String {
|
||||
"test utils command".to_string()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user