diff --git a/tests/integration/delete.bats b/tests/integration/delete.bats index ccb9108c9c6..9a6d7e1842a 100644 --- a/tests/integration/delete.bats +++ b/tests/integration/delete.bats @@ -85,8 +85,8 @@ EOF [[ "$output" =~ [0-9]+ ]] for s in ${subsystems}; do - name=CGROUP_${s^^} - eval path=\$"${name}"/foo + name=CGROUP_${s^^}_BASE_PATH + eval path=\$"${name}${REL_CGROUPS_PATH}/foo" # shellcheck disable=SC2154 [ -d "${path}" ] || fail "test failed to create memory sub-cgroup ($path not found)" done diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index a35ec62d71e..6fcb122b3e0 100644 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -149,11 +149,11 @@ function init_cgroup_paths() { else CGROUP_UNIFIED=no CGROUP_SUBSYSTEMS=$(awk '!/^#/ {print $1}' /proc/cgroups) + local g base_path for g in ${CGROUP_SUBSYSTEMS}; do base_path=$(gawk '$(NF-2) == "cgroup" && $NF ~ /\<'${g}'\>/ { print $5; exit }' /proc/self/mountinfo) test -z "$base_path" && continue eval CGROUP_${g^^}_BASE_PATH="${base_path}" - eval CGROUP_${g^^}="${base_path}${REL_CGROUPS_PATH}" done fi } @@ -167,14 +167,16 @@ function set_cgroups_path() { # Helper to check a value in cgroups. function check_cgroup_value() { - source=$1 - expected=$2 + local source=$1 + local expected=$2 + local cgroup var current if [ "x$CGROUP_UNIFIED" = "xyes" ]; then cgroup=$CGROUP_PATH else - ctrl=${source%%.*} - eval cgroup=\$CGROUP_${ctrl^^} + var=${source%%.*} # controller name (e.g. memory) + var=CGROUP_${var^^}_BASE_PATH # variable name (e.g. CGROUP_MEMORY_BASE_PATH) + eval cgroup=\$${var}${REL_CGROUPS_PATH} fi current=$(cat $cgroup/$source) diff --git a/tests/integration/update.bats b/tests/integration/update.bats index bea67312d2c..149da63cff9 100644 --- a/tests/integration/update.bats +++ b/tests/integration/update.bats @@ -532,10 +532,12 @@ EOF [[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup requires cgroups_v1 cgroups_rt no_systemd - # By default, "${CGROUP_CPU}/cpu.rt_runtime_us" is set to 0, which inhibits + local cgroup_cpu="${CGROUP_CPU_BASE_PATH}/${REL_CGROUPS_PATH}" + + # By default, "${cgroup_cpu}/cpu.rt_runtime_us" is set to 0, which inhibits # setting the container's realtimeRuntime. (#2046) # - # When $CGROUP_CPU is "/sys/fs/cgroup/cpu,cpuacct/runc-cgroups-integration-test/test-cgroup", + # When ${cgroup_cpu} is "/sys/fs/cgroup/cpu,cpuacct/runc-cgroups-integration-test/test-cgroup", # we write the values of /sys/fs/cgroup/cpu,cpuacct/cpu.rt_{period,runtime}_us to: # - sys/fs/cgroup/cpu,cpuacct/runc-cgroups-integration-test/cpu.rt_{period,runtime}_us # - sys/fs/cgroup/cpu,cpuacct/runc-cgroups-integration-test/test-cgroup/cpu.rt_{period,runtime}_us @@ -543,12 +545,12 @@ EOF # Typically period=1000000 runtime=950000 . # # TODO: support systemd - mkdir -p "$CGROUP_CPU" + mkdir -p "$cgroup_cpu" local root_period root_runtime root_period=$(cat "${CGROUP_CPU_BASE_PATH}/cpu.rt_period_us") root_runtime=$(cat "${CGROUP_CPU_BASE_PATH}/cpu.rt_runtime_us") # the following IFS magic sets dirs=("runc-cgroups-integration-test" "test-cgroup") - IFS='/' read -r -a dirs <<<"${CGROUP_CPU//${CGROUP_CPU_BASE_PATH}/}" + IFS='/' read -r -a dirs <<<"$REL_CGROUPS_PATH" for ((i = 0; i < ${#dirs[@]}; i++)); do local target="$CGROUP_CPU_BASE_PATH" for ((j = 0; j <= i; j++)); do