-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
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
40 changes: 40 additions & 0 deletions
40
tests/contest/contest/src/tests/linux_mount_label/linux_mount_label_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,40 @@ | ||
use test_framework::{Test, TestGroup, TestResult}; | ||
use oci_spec::runtime::{LinuxBuilder, ProcessBuilder, Spec, SpecBuilder}; | ||
use crate::utils::test_inside_container; | ||
|
||
fn create_spec(linux_mount_label: &str) -> Spec { | ||
SpecBuilder::default() | ||
.linux( | ||
// Need to reset the read-only paths | ||
LinuxBuilder::default() | ||
.mount_label(linux_mount_label) | ||
.readonly_paths(vec![]) | ||
.build() | ||
.expect("error in building linux config"), | ||
) | ||
.process( | ||
ProcessBuilder::default() | ||
.build() | ||
.expect("error in creating process config"), | ||
) | ||
.build() | ||
.unwrap() | ||
} | ||
|
||
// here we have to manually create and manage the container | ||
// as the test_inside container does not provide a way to set the pid file argument | ||
fn test_linux_mount_label() -> TestResult { | ||
let spec = create_spec("system_u:object_r:svirt_sandbox_file_t:s0:c715,c811"); | ||
test_inside_container(spec, &|_| { | ||
// As long as the container is created, we expect the hostname to be determined | ||
// by the spec, so nothing to prepare prior. | ||
Ok(()) | ||
}) | ||
} | ||
|
||
pub fn get_linux_mount_label_test() -> TestGroup { | ||
let linux_mount_label = Test::new("linux_mount_label", Box::new(test_linux_mount_label)); | ||
let mut tg = TestGroup::new("linux_mount_label"); | ||
tg.add(vec![Box::new(linux_mount_label)]); | ||
tg | ||
} |
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 linux_mount_label_test; | ||
pub use linux_mount_label_test::get_linux_mount_label_test; |
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