2014-04-22 08:44:22 +08:00
|
|
|
package gopsutil
|
2014-04-18 15:34:47 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCpu_times(t *testing.T) {
|
2014-04-22 09:02:01 +08:00
|
|
|
v, err := Cpu_times()
|
2014-04-18 15:34:47 +08:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf("error %v", err)
|
|
|
|
}
|
|
|
|
if len(v) == 0 {
|
|
|
|
t.Errorf("could not get CPUs ", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, vv := range v {
|
|
|
|
if vv.User == 0 {
|
|
|
|
t.Errorf("could not get CPU User: %v", vv)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCpu_counts(t *testing.T) {
|
2014-04-22 09:02:01 +08:00
|
|
|
v, err := Cpu_counts()
|
2014-04-18 15:34:47 +08:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf("error %v", err)
|
|
|
|
}
|
|
|
|
if v == 0 {
|
|
|
|
t.Errorf("could not get CPU counts: %v", v)
|
|
|
|
}
|
|
|
|
}
|