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

pull/43/merge
WAKAYAMA Shirou 10 years ago
parent ae3b0a48f4
commit ec2b509dda

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

Loading…
Cancel
Save