Skip to content

Commit

Permalink
[net] relax NetIOCounterAll test
Browse files Browse the repository at this point in the history
  • Loading branch information
shirou committed Nov 19, 2020
1 parent fd963e2 commit 34412e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion net/net_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package net

import (
"fmt"
"math"
"os"
"runtime"
"testing"
Expand Down Expand Up @@ -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)
}
}
Expand Down
4 changes: 3 additions & 1 deletion v3/net/net_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package net

import (
"fmt"
"math"
"os"
"runtime"
"testing"
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 34412e0

Please sign in to comment.