From 078c5edcd7337041d7dc95f8dd4e1c187b668e8d Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Thu, 16 Jan 2025 17:06:20 -0800 Subject: [PATCH] Adjust test to support cgroupv1 This has to be careful to do something non-destructive, which this *should* be. Signed-off-by: Tianon Gravi --- integration/container/run_linux_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/integration/container/run_linux_test.go b/integration/container/run_linux_test.go index ff9ce26e2d..8af460e0b5 100644 --- a/integration/container/run_linux_test.go +++ b/integration/container/run_linux_test.go @@ -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"))