[net] relax NetIOCounterAll test

pull/997/head
shirou 4 years ago
parent fd963e2e16
commit 34412e0b7f

@ -2,6 +2,7 @@ package net
import (
"fmt"
"math"
"os"
"runtime"
"testing"
@ -86,7 +87,7 @@ func TestNetIOCountersAll(t *testing.T) {
for _, p := range per {
pr += p.PacketsRecv
}
if v[0].PacketsRecv != pr {
if math.Abs(float64(v[0].PacketsRecv-pr)) > 5 {
t.Errorf("invalid sum value: %v, %v", v[0].PacketsRecv, pr)
}
}

@ -2,6 +2,7 @@ package net
import (
"fmt"
"math"
"os"
"runtime"
"testing"
@ -86,7 +87,8 @@ func TestNetIOCountersAll(t *testing.T) {
for _, p := range per {
pr += p.PacketsRecv
}
if v[0].PacketsRecv != pr {
// small diff is ok
if math.Abs(float64(v[0].PacketsRecv-pr)) > 5 {
t.Errorf("invalid sum value: %v, %v", v[0].PacketsRecv, pr)
}
}

Loading…
Cancel
Save