Adjust test to support cgroupv1

This has to be careful to do something non-destructive, which this *should* be.

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
This commit is contained in:
Tianon Gravi
2025-01-16 17:06:20 -08:00
parent c75e333b6f
commit 078c5edcd7

View File

@@ -467,7 +467,16 @@ func TestCgroupRW(t *testing.T) {
err = apiClient.ContainerStart(ctx, resp.ID, containertypes.StartOptions{})
assert.NilError(t, err)
res, err := container.Exec(ctx, apiClient, resp.ID, []string{"mkdir", "/sys/fs/cgroup/foo"})
res, err := container.Exec(ctx, apiClient, resp.ID, []string{"sh", "-ec", `
# see also "contrib/check-config.sh" for the same test
if [ "$(stat -f -c %t /sys/fs/cgroup 2> /dev/null)" = '63677270' ]; then
# nice, must be cgroupsv2
exec mkdir /sys/fs/cgroup/foo
else
# boo, must be cgroupsv1
exec mkdir /sys/fs/cgroup/pids/foo
fi
`})
assert.NilError(t, err)
if tc.expectedExitCode != 0 {
assert.Check(t, is.Contains(res.Stderr(), "Read-only file system"))