diff --git a/core/stat/internal/cgroup_linux_test.go b/core/stat/internal/cgroup_linux_test.go index 5b2eaeaa..a8a54678 100644 --- a/core/stat/internal/cgroup_linux_test.go +++ b/core/stat/internal/cgroup_linux_test.go @@ -12,27 +12,30 @@ func TestRunningInUserNS(t *testing.T) { assert.False(t, runningInUserNS()) } -func TestCgroupV1(t *testing.T) { - if isCgroup2UnifiedMode() { +func TestCgroups(t *testing.T) { + // test cgroup legacy(v1) & hybrid + if !isCgroup2UnifiedMode() { cg, err := currentCgroupV1() assert.NoError(t, err) _, err = cg.effectiveCpus() - assert.Error(t, err) + assert.NoError(t, err) _, err = cg.cpuQuota() - assert.Error(t, err) + assert.NoError(t, err) _, err = cg.cpuUsage() - assert.Error(t, err) + assert.NoError(t, err) } // test cgroup v2 - cg, err := currentCgroupV2() - assert.NoError(t, err) - _, err = cg.effectiveCpus() - assert.NoError(t, err) - _, err = cg.cpuQuota() - assert.Error(t, err) - _, err = cg.cpuUsage() - assert.NoError(t, err) + if isCgroup2UnifiedMode() { + cg, err := currentCgroupV2() + assert.NoError(t, err) + _, err = cg.effectiveCpus() + assert.NoError(t, err) + _, err = cg.cpuQuota() + assert.Error(t, err) + _, err = cg.cpuUsage() + assert.NoError(t, err) + } } func TestParseUint(t *testing.T) {