Disable gopsutil tests that don't work on darwin

This commit is contained in:
Evan Phoenix 2015-04-06 09:46:47 -07:00
parent d1cc82653a
commit 71461e7a49
2 changed files with 40 additions and 0 deletions

View File

@ -4,6 +4,8 @@ import (
"fmt" "fmt"
"runtime" "runtime"
"testing" "testing"
"github.com/shirou/gopsutil/common"
) )
func TestDisk_usage(t *testing.T) { func TestDisk_usage(t *testing.T) {
@ -36,6 +38,10 @@ func TestDisk_partitions(t *testing.T) {
func TestDisk_io_counters(t *testing.T) { func TestDisk_io_counters(t *testing.T) {
ret, err := DiskIOCounters() ret, err := DiskIOCounters()
if err != nil { if err != nil {
if err == common.NotImplementedError {
t.SkipNow()
}
t.Errorf("error %v", err) t.Errorf("error %v", err)
} }
if len(ret) == 0 { if len(ret) == 0 {

View File

@ -6,6 +6,8 @@ import (
"strings" "strings"
"testing" "testing"
"time" "time"
"github.com/shirou/gopsutil/common"
) )
func testGetProcess() Process { func testGetProcess() Process {
@ -60,6 +62,10 @@ func Test_Process_memory_maps(t *testing.T) {
mmaps, err := ret.MemoryMaps(false) mmaps, err := ret.MemoryMaps(false)
if err != nil { if err != nil {
if err == common.NotImplementedError {
t.SkipNow()
}
t.Errorf("memory map get error %v", err) t.Errorf("memory map get error %v", err)
} }
empty := MemoryMapsStat{} empty := MemoryMapsStat{}
@ -123,6 +129,10 @@ func Test_Process_Terminal(t *testing.T) {
_, err := p.Terminal() _, err := p.Terminal()
if err != nil { if err != nil {
if err == common.NotImplementedError {
t.SkipNow()
}
t.Errorf("geting terminal error %v", err) t.Errorf("geting terminal error %v", err)
} }
@ -138,6 +148,10 @@ func Test_Process_IOCounters(t *testing.T) {
v, err := p.IOCounters() v, err := p.IOCounters()
if err != nil { if err != nil {
if err == common.NotImplementedError {
t.SkipNow()
}
t.Errorf("geting iocounter error %v", err) t.Errorf("geting iocounter error %v", err)
return return
} }
@ -152,6 +166,10 @@ func Test_Process_NumCtx(t *testing.T) {
_, err := p.NumCtxSwitches() _, err := p.NumCtxSwitches()
if err != nil { if err != nil {
if err == common.NotImplementedError {
t.SkipNow()
}
t.Errorf("geting numctx error %v", err) t.Errorf("geting numctx error %v", err)
return return
} }
@ -173,6 +191,10 @@ func Test_Process_NumThread(t *testing.T) {
n, err := p.NumThreads() n, err := p.NumThreads()
if err != nil { if err != nil {
if err == common.NotImplementedError {
t.SkipNow()
}
t.Errorf("geting NumThread error %v", err) t.Errorf("geting NumThread error %v", err)
} }
if n < 0 { if n < 0 {
@ -196,6 +218,10 @@ func Test_Process_Exe(t *testing.T) {
n, err := p.Exe() n, err := p.Exe()
if err != nil { if err != nil {
if err == common.NotImplementedError {
t.SkipNow()
}
t.Errorf("geting Exe error %v", err) t.Errorf("geting Exe error %v", err)
} }
if !strings.Contains(n, "process.test") { if !strings.Contains(n, "process.test") {
@ -207,6 +233,10 @@ func Test_Process_CpuPercent(t *testing.T) {
p := testGetProcess() p := testGetProcess()
percent, err := p.CPUPercent(0) percent, err := p.CPUPercent(0)
if err != nil { if err != nil {
if err == common.NotImplementedError {
t.SkipNow()
}
t.Errorf("error %v", err) t.Errorf("error %v", err)
} }
duration := time.Duration(1000) * time.Microsecond duration := time.Duration(1000) * time.Microsecond
@ -231,6 +261,10 @@ func Test_Process_CpuPercentLoop(t *testing.T) {
duration := time.Duration(100) * time.Microsecond duration := time.Duration(100) * time.Microsecond
percent, err := p.CPUPercent(duration) percent, err := p.CPUPercent(duration)
if err != nil { if err != nil {
if err == common.NotImplementedError {
t.SkipNow()
}
t.Errorf("error %v", err) t.Errorf("error %v", err)
} }
// if percent < 0.0 || percent > 100.0*float64(numcpu) { // TODO // if percent < 0.0 || percent > 100.0*float64(numcpu) { // TODO