mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Assert UpdatedAtNanos in neighbor cache tests
Changes the neighbor_cache_test.go tests to always assert UpdatedAtNanos. Completes the assertion of UpdatedAtNanos in every NUD test, a field that was historically not checked due to the lack of a deterministic, controllable clock. This is no longer true with the tcpip.Clock interface. While the tests have been adjusted to use Clock, asserting by the UpdatedAtNanos was neglected. Fixes #4663 PiperOrigin-RevId: 360730077
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -18,13 +18,11 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
"gvisor.dev/gvisor/pkg/tcpip"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/faketime"
|
||||
"gvisor.dev/gvisor/pkg/tcpip/header"
|
||||
@@ -52,23 +50,6 @@ func runImmediatelyScheduledJobs(clock *faketime.ManualClock) {
|
||||
clock.Advance(immediateDuration)
|
||||
}
|
||||
|
||||
// eventDiffOpts are the options passed to cmp.Diff to compare entry events.
|
||||
// The UpdatedAtNanos field is ignored due to a lack of a deterministic method
|
||||
// to predict the time that an event will be dispatched.
|
||||
func eventDiffOpts() []cmp.Option {
|
||||
return []cmp.Option{
|
||||
cmpopts.IgnoreFields(NeighborEntry{}, "UpdatedAtNanos"),
|
||||
}
|
||||
}
|
||||
|
||||
// eventDiffOptsWithSort is like eventDiffOpts but also includes an option to
|
||||
// sort slices of events for cases where ordering must be ignored.
|
||||
func eventDiffOptsWithSort() []cmp.Option {
|
||||
return append(eventDiffOpts(), cmpopts.SortSlices(func(a, b testEntryEventInfo) bool {
|
||||
return strings.Compare(string(a.Entry.Addr), string(b.Entry.Addr)) < 0
|
||||
}))
|
||||
}
|
||||
|
||||
// The following unit tests exercise every state transition and verify its
|
||||
// behavior with RFC 4681 and RFC 7048.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user