tests/int/cgroups: use heredoc to break a long line

This is mostly to improve readability. While at it, make the script more
robust by adding -e option to shell. The exception is echo $pid which is
opportunistic and may fail depending on the order of pids in the file.

Also, remove the empty comment and a shellcheck annotation.

Fixes: c91fe9ae
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2025-10-18 13:04:06 -07:00
parent b82ae3afdc
commit 3c2683f52f
+7 -3
View File
@@ -113,11 +113,15 @@ function setup() {
[[ ${lines[0]} = "0::/foo" ]]
# teardown: remove "/foo"
# shellcheck disable=SC2016
runc exec test_cgroups_group sh -uxc 'echo -memory > /sys/fs/cgroup/cgroup.subtree_control; for f in $(cat /sys/fs/cgroup/foo/cgroup.procs); do echo $f > /sys/fs/cgroup/cgroup.procs; done; rmdir /sys/fs/cgroup/foo'
cat <<'EOF' | runc exec test_cgroups_group sh -eux
echo -memory > /sys/fs/cgroup/cgroup.subtree_control
for pid in $(cat /sys/fs/cgroup/foo/cgroup.procs); do
echo $pid > /sys/fs/cgroup/cgroup.procs || true
done
rmdir /sys/fs/cgroup/foo
EOF
runc exec test_cgroups_group test ! -d /sys/fs/cgroup/foo
[ "$status" -eq 0 ]
#
}
@test "runc run (cgroup v1 + unified resources should fail)" {