diff --git a/tests/contest/contest/src/tests/domainname/mod.rs b/tests/contest/contest/src/tests/domainname/mod.rs index 81ad9589d..b8eb4c682 100644 --- a/tests/contest/contest/src/tests/domainname/mod.rs +++ b/tests/contest/contest/src/tests/domainname/mod.rs @@ -1,4 +1,4 @@ -use crate::utils::test_inside_container; +use crate::utils::{is_runtime_runc, test_inside_container}; use oci_spec::runtime::{ProcessBuilder, Spec, SpecBuilder}; use test_framework::{ConditionalTest, TestGroup, TestResult}; @@ -27,10 +27,7 @@ pub fn get_domainname_tests() -> TestGroup { let mut tg = TestGroup::new("domainname_test"); let set_domainname_test = ConditionalTest::new( "set_domainname_test", - Box::new(|| match std::env::var("RUNTIME_KIND") { - Err(_) => true, - Ok(s) => s != "runc", - }), + Box::new(|| !is_runtime_runc()), Box::new(set_domainname_test), ); tg.add(vec![Box::new(set_domainname_test)]); diff --git a/tests/contest/contest/src/tests/scheduler/scheduler_policy.rs b/tests/contest/contest/src/tests/scheduler/scheduler_policy.rs index 431db4141..bbf68712d 100644 --- a/tests/contest/contest/src/tests/scheduler/scheduler_policy.rs +++ b/tests/contest/contest/src/tests/scheduler/scheduler_policy.rs @@ -4,7 +4,7 @@ use oci_spec::runtime::{ }; use test_framework::{test_result, ConditionalTest, TestGroup, TestResult}; -use crate::utils::test_inside_container; +use crate::utils::{is_runtime_runc, test_inside_container}; fn create_spec(policy: LinuxSchedulerPolicy, execute_test: &str) -> Result { let sc = SchedulerBuilder::default() @@ -48,18 +48,12 @@ pub fn get_scheduler_test() -> TestGroup { let mut scheduler_policy_group = TestGroup::new("set_scheduler_policy"); let policy_fifo_test = ConditionalTest::new( "policy_other", - Box::new(|| match std::env::var("RUNTIME_KIND") { - Err(_) => true, - Ok(s) => s != "runc", - }), + Box::new(|| !is_runtime_runc()), Box::new(scheduler_policy_other_test), ); let policy_rr_test = ConditionalTest::new( "policy_batch", - Box::new(|| match std::env::var("RUNTIME_KIND") { - Err(_) => true, - Ok(s) => s != "runc", - }), + Box::new(|| !is_runtime_runc()), Box::new(scheduler_policy_batch_test), ); diff --git a/tests/contest/contest/src/utils/mod.rs b/tests/contest/contest/src/utils/mod.rs index 77789fe55..fe546b87a 100644 --- a/tests/contest/contest/src/utils/mod.rs +++ b/tests/contest/contest/src/utils/mod.rs @@ -1,8 +1,8 @@ pub mod support; pub mod test_utils; pub use support::{ - generate_uuid, get_project_path, get_runtime_path, get_runtimetest_path, prepare_bundle, - set_config, set_runtime_path, + generate_uuid, get_project_path, get_runtime_path, get_runtimetest_path, is_runtime_runc, + prepare_bundle, set_config, set_runtime_path, }; pub use test_utils::{ create_container, delete_container, get_state, kill_container, test_inside_container, diff --git a/tests/contest/contest/src/utils/support.rs b/tests/contest/contest/src/utils/support.rs index 9f735d71b..b86f848ff 100644 --- a/tests/contest/contest/src/utils/support.rs +++ b/tests/contest/contest/src/utils/support.rs @@ -91,3 +91,10 @@ pub fn set_config>(project_path: P, config: &Spec) -> Result<()> config.save(path)?; Ok(()) } + +pub fn is_runtime_runc() -> bool { + match std::env::var("RUNTIME_KIND") { + Err(_) => false, + Ok(s) => s == "runc", + } +}