From c06661f041f0fcef4bed0f44feecef1e1a5abe3e Mon Sep 17 00:00:00 2001 From: Danila Kiver Date: Sun, 15 Sep 2019 21:28:13 +0300 Subject: Check for rootless before checking cgroups version in spec_test. Signed-off-by: Danila Kiver --- pkg/spec/spec_test.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/spec/spec_test.go b/pkg/spec/spec_test.go index 54d964a3a..2f91e1b21 100644 --- a/pkg/spec/spec_test.go +++ b/pkg/spec/spec_test.go @@ -36,13 +36,15 @@ func doCommonSkipChecks(t *testing.T) { t.Skip("seccomp, which is enabled by default, is only supported on Linux") } - isUnified, err := cgroups.IsCgroup2UnifiedMode() - if err != nil { - t.Errorf("unexpected error: %v", err) - } - - if rootless.IsRootless() && !isUnified { - t.Skip("cgroups v1 cannot be used when rootless") + if rootless.IsRootless() { + isCgroupV2, err := cgroups.IsCgroup2UnifiedMode() + if err != nil { + t.Errorf("unexpected error: %v", err) + } + + if !isCgroupV2 { + t.Skip("cgroups v1 cannot be used when rootless") + } } } -- cgit v1.2.3-54-g00ecf