Skip to content

Commit

Permalink
cpu: skip percpu percent test if windows. Windows can only get one CP…
Browse files Browse the repository at this point in the history
…U info currently.
  • Loading branch information
shirou committed Mar 7, 2015
1 parent ae3b0a4 commit ec2b509
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cpu/cpu_test.go
Expand Up @@ -62,13 +62,15 @@ func TestCpuInfo(t *testing.T) {
}

func testCPUPercent(t *testing.T, percpu bool) {
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)
if runtime.GOOS != "windows" {
v, err := CPUPercent(time.Millisecond, percpu)
if err != nil {
t.Errorf("error %v", err)
}
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
Expand Down

0 comments on commit ec2b509

Please sign in to comment.