From 257018e76cf439d66393b1cb04c34814088e6542 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 21 Jul 2021 12:38:52 -0700 Subject: [PATCH] tests/int: fix "update rt period and runtime" for rootless Since commit f09a3e1b8db33768, the value passed on to read starts with a slash, resulting in the first element of the array to be empty. As a result, the test tries to write to the top-level cgroup, which fails when rootless: > # Writing 1000000 to /sys/fs/cgroup/cpu,cpuacct//cpu.rt_period_us > # /tmp/bats-run-106184/bats.115768.src: line 548: /sys/fs/cgroup/cpu,cpuacct//cpu.rt_period_us: Permission denied To fix, remove the leading slash. An alternative fix would be to do "for ((i = 1;" instead of "i = 0", but that seems less readable. Fixes: f09a3e1b8db33768 Signed-off-by: Kir Kolyshkin (cherry picked from commit 86af5248662670247552296e45a68632be1c1470) Signed-off-by: Akihiro Suda --- tests/integration/update.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/update.bats b/tests/integration/update.bats index d51e93d0d..2004d9efc 100644 --- a/tests/integration/update.bats +++ b/tests/integration/update.bats @@ -537,7 +537,7 @@ EOF 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 <<<"$REL_CGROUPS_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