shirou_gopsutil/docker/docker_linux_test.go

47 lines
787 B
Go
Raw Normal View History

2014-06-10 13:38:01 +08:00
// +build linux
package gopsutil
import (
"testing"
)
func TestGetDockerIDList(t *testing.T) {
// If there is not docker environment, this test always fail.
// not tested here
/*
2014-08-16 01:18:30 +08:00
_, err := GetDockerIDList()
if err != nil {
t.Errorf("error %v", err)
}
*/
2014-06-10 13:38:01 +08:00
}
func TestCgroupCPU(t *testing.T) {
v, _ := GetDockerIDList()
for _, id := range v {
v, err := CgroupCPUDocker(id)
if err != nil {
t.Errorf("error %v", err)
}
if v.CPU == "" {
t.Errorf("could not get CgroupCPU %v", v)
}
}
}
func TestCgroupMem(t *testing.T) {
v, _ := GetDockerIDList()
for _, id := range v {
v, err := CgroupMemDocker(id)
if err != nil {
t.Errorf("error %v", err)
}
empty := &CgroupMemStat{}
if v == empty {
t.Errorf("Could not CgroupMemStat %v", v)
}
}
}