Skip to content

Commit

Permalink
linux_mount_label integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekko0114 committed Feb 12, 2024
1 parent 701085d commit 977ca3a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/contest/contest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::tests::hooks::get_hooks_tests;
use crate::tests::hostname::get_hostname_test;
use crate::tests::intel_rdt::get_intel_rdt_test;
use crate::tests::lifecycle::{ContainerCreate, ContainerLifecycle};
use crate::tests::linux_mount_label::get_linux_mount_label_test;
use crate::tests::linux_ns_itype::get_ns_itype_tests;
use crate::tests::mounts_recursive::get_mounts_recursive_test;
use crate::tests::pidfile::get_pidfile_test;
Expand Down Expand Up @@ -107,6 +108,7 @@ fn main() -> Result<()> {
let intel_rdt = get_intel_rdt_test();
let sysctl = get_sysctl_test();
let scheduler = get_scheduler_test();
let linux_mount_label = get_linux_mount_label_test();

tm.add_test_group(Box::new(cl));
tm.add_test_group(Box::new(cc));
Expand All @@ -124,6 +126,7 @@ fn main() -> Result<()> {
tm.add_test_group(Box::new(seccomp_notify));
tm.add_test_group(Box::new(ro_paths));
tm.add_test_group(Box::new(hostname));
tm.add_test_group(Box::new(linux_mount_label));
tm.add_test_group(Box::new(mounts_recursive));
tm.add_test_group(Box::new(domainname));
tm.add_test_group(Box::new(intel_rdt));
Expand Down
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
}
2 changes: 2 additions & 0 deletions tests/contest/contest/src/tests/linux_mount_label/mod.rs
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;
1 change: 1 addition & 0 deletions tests/contest/contest/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod hooks;
pub mod hostname;
pub mod intel_rdt;
pub mod lifecycle;
pub mod linux_mount_label;
pub mod linux_ns_itype;
pub mod mounts_recursive;
pub mod pidfile;
Expand Down

0 comments on commit 977ca3a

Please sign in to comment.