2015-05-29 14:22:21 -04:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"path"
|
|
|
|
|
2015-07-16 19:00:55 -04:00
|
|
|
"github.com/opencontainers/runc/libcontainer/cgroups"
|
2015-05-29 14:22:21 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2015-07-22 08:59:24 -04:00
|
|
|
cpuCfsPeriod = testRequirement{
|
2015-05-29 14:22:21 -04:00
|
|
|
func() bool {
|
2015-07-22 08:59:24 -04:00
|
|
|
cgroupCPUMountpoint, err := cgroups.FindCgroupMountpoint("cpu")
|
2015-05-29 14:22:21 -04:00
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
}
|
2015-07-22 08:59:24 -04:00
|
|
|
if _, err := ioutil.ReadFile(path.Join(cgroupCPUMountpoint, "cpu.cfs_period_us")); err != nil {
|
2015-05-29 14:22:21 -04:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
"Test requires an environment that supports cgroup cfs period.",
|
|
|
|
}
|
2015-07-22 08:59:24 -04:00
|
|
|
cpuCfsQuota = testRequirement{
|
2015-05-29 14:22:21 -04:00
|
|
|
func() bool {
|
2015-07-22 08:59:24 -04:00
|
|
|
cgroupCPUMountpoint, err := cgroups.FindCgroupMountpoint("cpu")
|
2015-05-29 14:22:21 -04:00
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
}
|
2015-07-22 08:59:24 -04:00
|
|
|
if _, err := ioutil.ReadFile(path.Join(cgroupCPUMountpoint, "cpu.cfs_quota_us")); err != nil {
|
2015-05-29 14:22:21 -04:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
},
|
|
|
|
"Test requires an environment that supports cgroup cfs quota.",
|
|
|
|
}
|
2015-07-22 08:59:24 -04:00
|
|
|
oomControl = testRequirement{
|
2015-07-08 16:30:03 -04:00
|
|
|
func() bool {
|
|
|
|
cgroupMemoryMountpoint, err := cgroups.FindCgroupMountpoint("memory")
|
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if _, err := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes")); err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.oom_control")); err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
|
|
|
|
},
|
|
|
|
"Test requires Oom control enabled.",
|
|
|
|
}
|
2015-05-29 14:22:21 -04:00
|
|
|
)
|