cpu: skip percpu percent test if windows. Windows can only get one CPU info currently.

This commit is contained in:
WAKAYAMA Shirou 2015-03-07 21:52:43 +09:00
parent ae3b0a48f4
commit ec2b509dda
1 changed files with 8 additions and 6 deletions

View File

@ -62,14 +62,16 @@ func TestCpuInfo(t *testing.T) {
}
func testCPUPercent(t *testing.T, percpu bool) {
numcpu := runtime.NumCPU()
if runtime.GOOS != "windows" {
v, err := CPUPercent(time.Millisecond, percpu)
if err != nil {
t.Errorf("error %v", err)
}
numcpu := runtime.NumCPU()
if (percpu && len(v) != numcpu) || (!percpu && len(v) != 1) {
t.Fatalf("wrong number of entries from CPUPercent: %v", v)
}
}
for i := 0; i < 100; i++ {
duration := time.Duration(10) * time.Microsecond
v, err := CPUPercent(duration, percpu)