Skip to content

Commit

Permalink
tests/int: fix "update rt period and runtime" for rootless
Browse files Browse the repository at this point in the history
Since commit f09a3e1, 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: f09a3e1
Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin authored and adrianreber committed Jul 23, 2021
1 parent 713748d commit 86af524
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/integration/update.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 86af524

Please sign in to comment.