diff --git a/tests/integration/cgroups.bats b/tests/integration/cgroups.bats index 7ad233a15b0..0d5577dd958 100644 --- a/tests/integration/cgroups.bats +++ b/tests/integration/cgroups.bats @@ -16,10 +16,7 @@ function setup() { } @test "runc create (rootless + no limits + cgrouppath + no permission) fails with permission error" { - requires rootless - requires rootless_no_cgroup - # systemd controls the permission, so error does not happen - requires no_systemd + requires rootless rootless_no_cgroup set_cgroups_path @@ -29,10 +26,7 @@ function setup() { } @test "runc create (rootless + limits + no cgrouppath + no permission) fails with informative error" { - requires rootless - requires rootless_no_cgroup - # systemd controls the permission, so error does not happen - requires no_systemd + requires rootless rootless_no_cgroup set_resources_limit diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index 30fdf3e049a..7eb43de2adf 100644 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -271,6 +271,11 @@ function fail() { exit 1 } +# Check whether rootless runc can use cgroups. +function rootless_cgroup() { + [[ "$ROOTLESS_FEATURES" == *"cgroup"* || -n "$RUNC_USE_SYSTEMD" ]] +} + # Allows a test to specify what things it requires. If the environment can't # support it, the test is skipped with a message. function requires() { @@ -298,12 +303,12 @@ function requires() { fi ;; rootless_cgroup) - if [[ "$ROOTLESS_FEATURES" != *"cgroup"* ]]; then + if ! rootless_cgroup; then skip_me=1 fi ;; rootless_no_cgroup) - if [[ "$ROOTLESS_FEATURES" == *"cgroup"* ]]; then + if rootless_cgroup; then skip_me=1 fi ;; diff --git a/tests/integration/update.bats b/tests/integration/update.bats index bc9005663d3..e204ea49550 100644 --- a/tests/integration/update.bats +++ b/tests/integration/update.bats @@ -21,7 +21,7 @@ function setup() { # Tests whatever limits are (more or less) common between cgroup # v1 and v2: memory/swap, pids, and cpuset. @test "update cgroup v1/v2 common limits" { - [[ "$ROOTLESS" -ne 0 && -z "$RUNC_USE_SYSTEMD" ]] && requires rootless_cgroup + [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup requires cgroups_memory cgroups_pids cgroups_cpuset init_cgroup_paths