Merge pull request #980 from shirou/feature/fix_tests_and_not_implemented_error

fix test and openbsd errors.
tags/v3.20.10
shirou 5 years ago committed by GitHub
commit bb232c46d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -59,11 +59,23 @@ func TestCpu_times(t *testing.T) {
perCPUIdleTimeSum += pc.Idle
}
margin := 2.0
t.Log(cpuTotal[0])
if cpuTotal[0].User == 0 && cpuTotal[0].System == 0 && cpuTotal[0].Idle == 0 {
t.Error("could not get cpu values")
}
if cpuTotal[0].User != 0 {
assert.InEpsilon(t, cpuTotal[0].User, perCPUUserTimeSum, margin)
}
if cpuTotal[0].System != 0 {
assert.InEpsilon(t, cpuTotal[0].System, perCPUSystemTimeSum, margin)
}
if cpuTotal[0].Idle != 0 {
assert.InEpsilon(t, cpuTotal[0].Idle, perCPUIdleTimeSum, margin)
}
}
func TestCpu_counts(t *testing.T) {
v, err := Counts(true)
skipIfNotImplementedErr(t, err)

@ -121,15 +121,15 @@ func TestUserStat_String(t *testing.T) {
}
func TestHostGuid(t *testing.T) {
hi, err := Info()
id, err := HostID()
skipIfNotImplementedErr(t, err)
if err != nil {
t.Error(err)
}
if hi.HostID == "" {
if id == "" {
t.Error("Host id is empty")
} else {
t.Logf("Host id value: %v", hi.HostID)
t.Logf("Host id value: %v", id)
}
}

@ -4,7 +4,6 @@ package net
import (
"context"
"errors"
"fmt"
"os/exec"
"regexp"
@ -153,7 +152,7 @@ func FilterCounters() ([]FilterStat, error) {
}
func FilterCountersWithContext(ctx context.Context) ([]FilterStat, error) {
return nil, errors.New("NetFilterCounters not implemented for openbsd")
return nil, common.ErrNotImplementedError
}
func ConntrackStats(percpu bool) ([]ConntrackStat, error) {
@ -173,7 +172,7 @@ func ProtoCounters(protocols []string) ([]ProtoCountersStat, error) {
}
func ProtoCountersWithContext(ctx context.Context, protocols []string) ([]ProtoCountersStat, error) {
return nil, errors.New("NetProtoCounters not implemented for openbsd")
return nil, common.ErrNotImplementedError
}
func parseNetstatLine(line string) (ConnectionStat, error) {

Loading…
Cancel
Save