mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 20:24:31 +00:00
agent: check command before do test_ip_tables
test_ip_tables test depends on iptables tools. But we can't ensure these tools are exist. it's better to skip the test if there is no such tools. Fixes: #5697 Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
This commit is contained in:
parent
65686dbbdc
commit
b53171b605
7
src/agent/Cargo.lock
generated
7
src/agent/Cargo.lock
generated
@ -696,6 +696,7 @@ dependencies = [
|
||||
"tracing-subscriber",
|
||||
"ttrpc",
|
||||
"vsock-exporter",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2184,13 +2185,13 @@ checksum = "6a89911bd99e5f3659ec4acf9c4d93b0a90fe4a2a11f15328472058edc5261be"
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.2.5"
|
||||
version = "4.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae"
|
||||
checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b"
|
||||
dependencies = [
|
||||
"either",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -69,6 +69,7 @@ clap = { version = "3.0.1", features = ["derive"] }
|
||||
[dev-dependencies]
|
||||
tempfile = "3.1.0"
|
||||
test-utils = { path = "../libs/test-utils" }
|
||||
which = "4.3.0"
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
|
@ -2032,6 +2032,11 @@ mod tests {
|
||||
use tempfile::{tempdir, TempDir};
|
||||
use test_utils::{assert_result, skip_if_not_root};
|
||||
use ttrpc::{r#async::TtrpcContext, MessageHeader};
|
||||
use which::which;
|
||||
|
||||
fn check_command(cmd: &str) -> bool {
|
||||
which(cmd).is_ok()
|
||||
}
|
||||
|
||||
fn mk_ttrpc_context() -> TtrpcContext {
|
||||
TtrpcContext {
|
||||
@ -2751,6 +2756,18 @@ OtherField:other
|
||||
async fn test_ip_tables() {
|
||||
skip_if_not_root!();
|
||||
|
||||
if !check_command(IPTABLES_SAVE)
|
||||
|| !check_command(IPTABLES_RESTORE)
|
||||
|| !check_command(IP6TABLES_SAVE)
|
||||
|| !check_command(IP6TABLES_RESTORE)
|
||||
{
|
||||
warn!(
|
||||
sl!(),
|
||||
"one or more commands for ip tables test are missing, skip it"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
let logger = slog::Logger::root(slog::Discard, o!());
|
||||
let sandbox = Sandbox::new(&logger).unwrap();
|
||||
let agent_service = Box::new(AgentService {
|
||||
|
Loading…
Reference in New Issue
Block a user