mirror of
https://github.com/containers/youki
synced 2024-05-10 09:36:13 +02:00
464344923f
* Name the test tools `contest` Signed-off-by: utam0k <k0ma@utam0k.jp> * Address the feedbacks Signed-off-by: utam0k <k0ma@utam0k.jp> * Fix a build error Signed-off-by: utam0k <k0ma@utam0k.jp> * Fix a workflow Signed-off-by: utam0k <k0ma@utam0k.jp> * Address the feedbacks Signed-off-by: utam0k <k0ma@utam0k.jp> --------- Signed-off-by: utam0k <k0ma@utam0k.jp>
45 lines
1.3 KiB
Rust
45 lines
1.3 KiB
Rust
use std::collections::HashMap;
|
|
|
|
use oci_spec::runtime::{LinuxBuilder, ProcessBuilder, Spec, SpecBuilder};
|
|
use test_framework::{Test, TestGroup, TestResult};
|
|
|
|
use crate::utils::test_inside_container;
|
|
|
|
fn create_spec(sysctl: HashMap<String, String>) -> Spec {
|
|
SpecBuilder::default()
|
|
.linux(
|
|
LinuxBuilder::default()
|
|
.sysctl(sysctl)
|
|
.build()
|
|
.expect("error in building linux config"),
|
|
)
|
|
.process(
|
|
ProcessBuilder::default()
|
|
.args(vec!["runtimetest".to_string(), "sysctl".to_string()])
|
|
.build()
|
|
.expect("error in creating process config"),
|
|
)
|
|
.build()
|
|
.unwrap()
|
|
}
|
|
|
|
fn sysctl_test() -> TestResult {
|
|
let spec = create_spec(HashMap::from([(
|
|
"net.ipv4.ip_forward".to_string(),
|
|
"1".to_string(),
|
|
)]));
|
|
test_inside_container(spec, &|_| {
|
|
// As long as the container is created, we expect the kernel parameters to be determined by
|
|
// the spec, so nothing to prepare prior.
|
|
Ok(())
|
|
})
|
|
}
|
|
|
|
pub fn get_sysctl_test() -> TestGroup {
|
|
let mut test_group = TestGroup::new("sysctl");
|
|
let sysctl_test = Test::new("sysctl_test", Box::new(sysctl_test));
|
|
test_group.add(vec![Box::new(sysctl_test)]);
|
|
|
|
test_group
|
|
}
|