17244: Refactor crunchstat to use cgroup unified/hybrid modes.
[arvados.git] / lib / crunchrun / cgroup_test.go
index eb87456d14b0d1e0e60245460009d75cfe4a01b2..313ed9a254f7bdb3e4ba20ef053ada51d4ec002e 100644 (file)
@@ -5,6 +5,9 @@
 package crunchrun
 
 import (
+       "fmt"
+       "os/exec"
+
        . "gopkg.in/check.v1"
 )
 
@@ -13,6 +16,11 @@ type CgroupSuite struct{}
 var _ = Suite(&CgroupSuite{})
 
 func (s *CgroupSuite) TestFindCgroup(c *C) {
+       if buf, err := exec.Command("stat", "-ftc", "%T", "/sys/fs/cgroup").CombinedOutput(); err != nil {
+               c.Skip(fmt.Sprintf("cannot stat /sys/fs/cgroup: %s", err))
+       } else if string(buf) == "cgroup2fs\n" {
+               c.Skip("cannot test cgroups v1 feature because this system is using cgroups v2 unified mode")
+       }
        for _, s := range []string{"devices", "cpu", "cpuset"} {
                g, err := findCgroup(s)
                if c.Check(err, IsNil) {