diff options
author | Tamir Duberstein <tamird@google.com> | 2019-03-26 20:19:41 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-03-26 20:20:52 -0700 |
commit | 9c20a88bd7d49e275c43cad12f6325c52130dd42 (patch) | |
tree | bac96998dec11e360763ebccba177cbf4e86c068 /pkg/tcpip/network/ipv6 | |
parent | e9152d4a621ea3f83da4a064018bc32854330e6c (diff) |
Remove polling from ICMP test
PiperOrigin-RevId: 240483396
Change-Id: Ie75d3ae38af83f1d92f167ff9ba58fa10f5b372b
Diffstat (limited to 'pkg/tcpip/network/ipv6')
-rw-r--r-- | pkg/tcpip/network/ipv6/icmp_test.go | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/pkg/tcpip/network/ipv6/icmp_test.go b/pkg/tcpip/network/ipv6/icmp_test.go index 15574bab1..eee09f3af 100644 --- a/pkg/tcpip/network/ipv6/icmp_test.go +++ b/pkg/tcpip/network/ipv6/icmp_test.go @@ -15,8 +15,6 @@ package ipv6 import ( - "context" - "runtime" "strings" "testing" "time" @@ -181,29 +179,27 @@ func TestLinkResolution(t *testing.T) { t.Fatal(err) } - // This actually takes about 10 milliseconds, so no need to wait for - // a multi-minute go test timeout if something is broken. - ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) - defer cancel() - for { - if ctx.Err() != nil { - break + _, resCh, err := ep.Write(payload, tcpip.WriteOptions{To: &tcpip.FullAddress{NIC: 1, Addr: lladdr1}}) + if resCh != nil { + if err != tcpip.ErrNoLinkAddress { + t.Fatalf("ep.Write(_) = _, <non-nil>, %s want _, <non-nil>, tcpip.ErrNoLinkAddress", err) + } + <-resCh + continue } - if _, _, err := ep.Write(payload, tcpip.WriteOptions{To: &tcpip.FullAddress{NIC: 1, Addr: lladdr1}}); err == tcpip.ErrNoLinkAddress { - // There's something asynchronous going on; yield to let it do its thing. - runtime.Gosched() - } else if err == nil { - break - } else { - t.Fatal(err) + if err != nil { + t.Fatalf("ep.Write(_) = _, _, %s", err) } + break } stats := make(map[header.ICMPv6Type]int) for { + // This actually takes about 10 milliseconds, so no need to wait for + // a multi-minute go test timeout if something is broken. select { - case <-ctx.Done(): + case <-time.After(2 * time.Second): t.Errorf("timeout waiting for ICMP, got: %#+v", stats) return case icmpInfo := <-c.icmpCh: |