-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yusuke Sakurai <[email protected]>
- Loading branch information
Showing
8 changed files
with
218 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod rootfs_propagation_test; | ||
pub use rootfs_propagation_test::get_rootfs_propagation_test; |
102 changes: 102 additions & 0 deletions
102
tests/contest/contest/src/tests/rootfs_propagation/rootfs_propagation_test.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
use anyhow::{Context, Ok, Result}; | ||
use oci_spec::runtime::{ | ||
Capability, LinuxBuilder, LinuxCapabilitiesBuilder, LinuxSeccompBuilder, ProcessBuilder, | ||
RootBuilder, Spec, SpecBuilder, | ||
}; | ||
use test_framework::{test_result, Test, TestGroup, TestResult}; | ||
|
||
use crate::utils::test_inside_container; | ||
use crate::utils::test_utils::CreateOptions; | ||
|
||
fn create_spec(propagation: String) -> Result<Spec> { | ||
let root = RootBuilder::default() | ||
.readonly(false) | ||
.build() | ||
.context("failed to build root")?; | ||
|
||
let capabilities = LinuxCapabilitiesBuilder::default() | ||
.bounding([Capability::SysAdmin]) | ||
.effective([Capability::SysAdmin]) | ||
.inheritable([Capability::SysAdmin]) | ||
.permitted([Capability::SysAdmin]) | ||
.ambient([Capability::SysAdmin]) | ||
.build() | ||
.context("failed to build linux capabilities")?; | ||
|
||
let process = ProcessBuilder::default() | ||
.args(vec![ | ||
"runtimetest".to_string(), | ||
"rootfs_propagation".to_string(), | ||
]) | ||
.capabilities(capabilities) | ||
.build() | ||
.context("failed to build process")?; | ||
|
||
let seccomp = LinuxSeccompBuilder::default() | ||
.build() | ||
.context("failed to build seccomp")?; | ||
|
||
let linux = LinuxBuilder::default() | ||
.rootfs_propagation(propagation) | ||
.seccomp(seccomp) | ||
.build() | ||
.context("failed to build linux spec")?; | ||
|
||
let spec = SpecBuilder::default() | ||
.root(root) | ||
.linux(linux) | ||
.process(process) | ||
.build() | ||
.context("failed to build spec")?; | ||
|
||
Ok(spec) | ||
} | ||
|
||
fn rootfs_propagation_shared_test() -> TestResult { | ||
let spec = test_result!(create_spec("shared".to_string())); | ||
test_inside_container(spec, &CreateOptions::default(), &|_| Ok(())) | ||
} | ||
|
||
fn rootfs_propagation_slave_test() -> TestResult { | ||
let spec = test_result!(create_spec("slave".to_string())); | ||
test_inside_container(spec, &CreateOptions::default(), &|_| Ok(())) | ||
} | ||
|
||
fn rootfs_propagation_private_test() -> TestResult { | ||
let spec = test_result!(create_spec("private".to_string())); | ||
test_inside_container(spec, &CreateOptions::default(), &|_| Ok(())) | ||
} | ||
|
||
fn rootfs_propagation_unbindable_test() -> TestResult { | ||
let spec = test_result!(create_spec("unbindable".to_string())); | ||
test_inside_container(spec, &CreateOptions::default(), &|_| Ok(())) | ||
} | ||
|
||
pub fn get_rootfs_propagation_test() -> TestGroup { | ||
let mut rootfs_propagation_test_group = TestGroup::new("rootfs_propagation"); | ||
|
||
let rootfs_propagation_shared_test = Test::new( | ||
"rootfs_propagation_shared_test", | ||
Box::new(rootfs_propagation_shared_test), | ||
); | ||
let rootfs_propagation_slave_test = Test::new( | ||
"rootfs_propagation_slave_test", | ||
Box::new(rootfs_propagation_slave_test), | ||
); | ||
let rootfs_propagation_private_test = Test::new( | ||
"rootfs_propagation_private_test", | ||
Box::new(rootfs_propagation_private_test), | ||
); | ||
let rootfs_propagation_unbindable_test = Test::new( | ||
"rootfs_propagation_unbindable_test", | ||
Box::new(rootfs_propagation_unbindable_test), | ||
); | ||
rootfs_propagation_test_group.add(vec![ | ||
Box::new(rootfs_propagation_shared_test), | ||
Box::new(rootfs_propagation_slave_test), | ||
Box::new(rootfs_propagation_private_test), | ||
Box::new(rootfs_propagation_unbindable_test), | ||
]); | ||
|
||
rootfs_propagation_test_group | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ nix = "0.28.0" | |
anyhow = "1.0" | ||
libc = "0.2.169" # TODO (YJDoc2) upgrade to latest | ||
nc = "0.9.5" | ||
tempfile = "3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters