Skip to content

Commit

Permalink
Extract the runc check into a function
Browse files Browse the repository at this point in the history
Signed-off-by: Yashodhan Joshi <[email protected]>
  • Loading branch information
YJDoc2 committed Jan 23, 2024
1 parent 240584e commit 1451e3a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
7 changes: 2 additions & 5 deletions tests/contest/contest/src/tests/domainname/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::utils::test_inside_container;
use crate::utils::{support::is_runtime_runc, test_inside_container};
use oci_spec::runtime::{ProcessBuilder, Spec, SpecBuilder};
use test_framework::{ConditionalTest, TestGroup, TestResult};

Expand Down Expand Up @@ -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)]);
Expand Down
12 changes: 3 additions & 9 deletions tests/contest/contest/src/tests/scheduler/scheduler_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{support::is_runtime_runc, test_inside_container};

fn create_spec(policy: LinuxSchedulerPolicy, execute_test: &str) -> Result<Spec> {
let sc = SchedulerBuilder::default()
Expand Down Expand Up @@ -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),
);

Expand Down
7 changes: 7 additions & 0 deletions tests/contest/contest/src/utils/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,10 @@ pub fn set_config<P: AsRef<Path>>(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",
}
}

0 comments on commit 1451e3a

Please sign in to comment.