Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sepc into &spec in test_{outside,inside}_containe #3068

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/contest/contest/src/tests/cgroups/blkio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ fn test_blkio(test_name: &str, rate: u64, empty: bool) -> TestResult {
)
.unwrap();

test_outside_container(spec.clone(), &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(validate_block_io(test_name, &spec));
TestResult::Passed
Expand Down
8 changes: 4 additions & 4 deletions tests/contest/contest/src/tests/cgroups/cpu/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ fn test_cpu_cgroups() -> TestResult {

for case in cases.into_iter() {
let spec = test_result!(create_spec(cgroup_name, case));
let test_result = test_outside_container(spec, &|data| {
let test_result = test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));

TestResult::Passed
Expand All @@ -223,7 +223,7 @@ fn test_empty_cpu() -> TestResult {
let cgroup_name = "test_empty_cpu";
let spec = test_result!(create_empty_spec(cgroup_name));

test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
TestResult::Passed
})
Expand All @@ -249,7 +249,7 @@ fn test_cpu_idle_set() -> TestResult {
));

let spec = test_result!(create_spec(cgroup_name, cpu));
test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
TestResult::Passed
})
Expand All @@ -273,7 +273,7 @@ fn test_cpu_idle_default() -> TestResult {
realtime_runtime,
));
let spec = test_result!(create_spec(cgroup_name, cpu));
test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
TestResult::Passed
})
Expand Down
22 changes: 11 additions & 11 deletions tests/contest/contest/src/tests/cgroups/cpu/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn test_cpu_idle_set() -> TestResult {
.context("build cpu spec"));

let spec = test_result!(create_spec("test_cpu_idle_set", cpu));
test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_cpu_idle("test_cpu_idle_set", idle));
TestResult::Passed
Expand All @@ -48,7 +48,7 @@ fn test_cpu_idle_default() -> TestResult {
let cpu = test_result!(LinuxCpuBuilder::default().build().context("build cpu spec"));

let spec = test_result!(create_spec("test_cpu_idle_default", cpu));
test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_cpu_idle("test_cpu_idle_default", default_idle));
TestResult::Passed
Expand All @@ -65,7 +65,7 @@ fn test_cpu_weight_valid_set() -> TestResult {
.context("build cpu spec"));

let spec = test_result!(create_spec("test_cpu_weight_valid_set", cpu));
test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_cpu_weight(
"test_cpu_weight_valid_set",
Expand All @@ -85,7 +85,7 @@ fn test_cpu_weight_zero_ignored() -> TestResult {
.context("build cpu spec"));

let spec = test_result!(create_spec("test_cpu_weight_zero_ignored", cpu));
test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_cpu_weight(
"test_cpu_weight_zero_ignored",
Expand All @@ -105,7 +105,7 @@ fn test_cpu_weight_too_high_maximum_set() -> TestResult {
.context("build cpu spec"));

let spec = test_result!(create_spec("test_cpu_weight_too_high_maximum_set", cpu));
test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_cpu_weight(
"test_cpu_weight_too_high_maximum_set",
Expand All @@ -124,7 +124,7 @@ fn test_cpu_quota_valid_set() -> TestResult {
.context("build cpu spec"));

let spec = test_result!(create_spec("test_cpu_quota_valid_set", cpu));
test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_cpu_max(
"test_cpu_quota_valid_set",
Expand All @@ -144,7 +144,7 @@ fn test_cpu_quota_zero_default_set() -> TestResult {
.context("build cpu spec"));

let spec = test_result!(create_spec("test_cpu_quota_zero_default_set", cpu));
test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_cpu_max(
"test_cpu_quota_zero_default_set",
Expand All @@ -167,7 +167,7 @@ fn test_cpu_quota_negative_default_set() -> TestResult {
"test_cpu_quota_negative_value_default_set",
cpu
));
test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_cpu_max(
"test_cpu_quota_negative_value_default_set",
Expand Down Expand Up @@ -195,7 +195,7 @@ fn test_cpu_period_valid_set() -> TestResult {
&expected_period.to_string()
));

test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_cpu_max(
"test_cpu_period_valid_set",
Expand All @@ -220,7 +220,7 @@ fn test_cpu_quota_period_unspecified_unchanged() -> TestResult {
&expected_period.to_string()
));

test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_cpu_max(
"test_cpu_period_unspecified_unchanged",
Expand All @@ -242,7 +242,7 @@ fn test_cpu_period_and_quota_valid_set() -> TestResult {

let spec = test_result!(create_spec("test_cpu_period_and_quota_valid_set", cpu));

test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_cpu_max(
"test_cpu_period_and_quota_valid_set",
Expand Down
2 changes: 1 addition & 1 deletion tests/contest/contest/src/tests/cgroups/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn test_memory_cgroups() -> TestResult {
];

for spec in cases.into_iter() {
let test_result = test_outside_container(spec, &|data| {
let test_result = test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));

TestResult::Passed
Expand Down
2 changes: 1 addition & 1 deletion tests/contest/contest/src/tests/cgroups/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fn test_network_cgroups() -> TestResult {
];

for spec in cases.into_iter() {
let test_result = test_outside_container(spec, &|data| {
let test_result = test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));

TestResult::Passed
Expand Down
6 changes: 3 additions & 3 deletions tests/contest/contest/src/tests/cgroups/pids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn test_positive_limit() -> TestResult {
let limit = 50;
let spec = test_result!(create_spec(cgroup_name, limit));

test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_pid_limit_set(cgroup_name, limit));
TestResult::Passed
Expand All @@ -55,7 +55,7 @@ fn test_zero_limit() -> TestResult {
let limit = 0;
let spec = test_result!(create_spec(cgroup_name, limit));

test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_pids_are_unlimited(cgroup_name));
TestResult::Passed
Expand All @@ -68,7 +68,7 @@ fn test_negative_limit() -> TestResult {
let limit = -1;
let spec = test_result!(create_spec(cgroup_name, limit));

test_outside_container(spec, &|data| {
test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));
test_result!(check_pids_are_unlimited(cgroup_name));
TestResult::Passed
Expand Down
2 changes: 1 addition & 1 deletion tests/contest/contest/src/tests/devices/devices_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn create_spec() -> Result<Spec> {

fn devices_test() -> TestResult {
let spec = test_result!(create_spec());
test_inside_container(spec, &CreateOptions::default(), &|_| Ok(()))
test_inside_container(&spec, &CreateOptions::default(), &|_| Ok(()))
}

pub fn get_devices_test() -> TestGroup {
Expand Down
2 changes: 1 addition & 1 deletion tests/contest/contest/src/tests/domainname/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn get_spec(domainname: &str) -> Spec {

fn set_domainname_test() -> TestResult {
let spec = get_spec("domainname");
test_inside_container(spec, &CreateOptions::default(), &|_| Ok(()))
test_inside_container(&spec, &CreateOptions::default(), &|_| Ok(()))
}

pub fn get_domainname_tests() -> TestGroup {
Expand Down
2 changes: 1 addition & 1 deletion tests/contest/contest/src/tests/example/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn create_spec() -> Result<Spec> {
////////// ANCHOR: example_test
fn example_test() -> TestResult {
let spec = test_result!(create_spec());
test_inside_container(spec, &CreateOptions::default(), &|_| Ok(()))
test_inside_container(&spec, &CreateOptions::default(), &|_| Ok(()))
}
////////// ANCHOR_END: example_test

Expand Down
6 changes: 3 additions & 3 deletions tests/contest/contest/src/tests/fd_control/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn open_devnull_no_cloexec() -> Result<(fs::File, RawFd)> {
fn only_stdio_test() -> TestResult {
let spec = test_result!(create_spec());
test_inside_container(
spec,
&spec,
&CreateOptions::default().with_extra_args(&["--preserve-fds".as_ref(), "100".as_ref()]),
&|bundle_path| {
fs::write(bundle_path.join("num-fds"), "0".as_bytes())?;
Expand All @@ -60,7 +60,7 @@ fn closes_fd_test() -> TestResult {

let spec = test_result!(create_spec());
test_inside_container(
spec,
&spec,
&CreateOptions::default().with_extra_args(&["--preserve-fds".as_ref(), "0".as_ref()]),
&|bundle_path| {
fs::write(bundle_path.join("num-fds"), "0".as_bytes())?;
Expand All @@ -79,7 +79,7 @@ fn pass_single_fd_test() -> TestResult {

let spec = test_result!(create_spec());
test_inside_container(
spec,
&spec,
&CreateOptions::default().with_extra_args(&[
"--preserve-fds".as_ref(),
(devnull_fd - 2).to_string().as_ref(), // relative to stdio
Expand Down
4 changes: 2 additions & 2 deletions tests/contest/contest/src/tests/hostname/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn create_spec(hostname: &str) -> Spec {

fn hostname_test() -> TestResult {
let spec = create_spec("hostname-specific");
test_inside_container(spec, &CreateOptions::default(), &|_| {
test_inside_container(&spec, &CreateOptions::default(), &|_| {
// As long as the container is created, we expect the hostname to be determined
// by the spec, so nothing to prepare prior.
Ok(())
Expand All @@ -35,7 +35,7 @@ fn hostname_test() -> TestResult {

fn empty_hostname() -> TestResult {
let spec = create_spec("");
test_inside_container(spec, &CreateOptions::default(), &|_| {
test_inside_container(&spec, &CreateOptions::default(), &|_| {
// As long as the container is created, we expect the hostname to be determined
// by the spec, so nothing to prepare prior.
Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn test_intel_rdt() -> TestResult {
];

for spec in cases.into_iter() {
let test_result = test_outside_container(spec, &|data| {
let test_result = test_outside_container(&spec, &|data| {
test_result!(check_container_created(&data));

TestResult::Passed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn io_priority_class_rt_test() -> TestResult {
"io_priority_class_rt",
1,
));
test_inside_container(spec, &CreateOptions::default(), &|_| Ok(()))
test_inside_container(&spec, &CreateOptions::default(), &|_| Ok(()))
}

fn io_priority_class_be_test() -> TestResult {
Expand All @@ -48,7 +48,7 @@ fn io_priority_class_be_test() -> TestResult {
"io_priority_class_be",
2,
));
test_inside_container(spec, &CreateOptions::default(), &|_| Ok(()))
test_inside_container(&spec, &CreateOptions::default(), &|_| Ok(()))
}

fn io_priority_class_idle_test() -> TestResult {
Expand All @@ -57,7 +57,7 @@ fn io_priority_class_idle_test() -> TestResult {
"io_priority_class_idle",
3,
));
test_inside_container(spec, &CreateOptions::default(), &|_| Ok(()))
test_inside_container(&spec, &CreateOptions::default(), &|_| Ok(()))
}

pub fn get_io_priority_test() -> TestGroup {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn get_test(test_name: &'static str) -> Test {
}
};
let spec = get_spec();
test_outside_container(spec, &move |data| {
test_outside_container(&spec, &move |data| {
let pid = match data.state {
Some(s) => s.pid.unwrap(),
None => return TestResult::Failed(anyhow!("state command returned error")),
Expand Down
Loading