From ec2b509dda0deed10c35521b5ff742cdb813d034 Mon Sep 17 00:00:00 2001 From: WAKAYAMA Shirou Date: Sat, 7 Mar 2015 21:52:43 +0900 Subject: [PATCH] cpu: skip percpu percent test if windows. Windows can only get one CPU info currently. --- cpu/cpu_test.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cpu/cpu_test.go b/cpu/cpu_test.go index 490b129..1518fda 100644 --- a/cpu/cpu_test.go +++ b/cpu/cpu_test.go @@ -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