diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-05-11 11:02:51 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-05-11 11:04:31 -0700 |
commit | c5ab21b04857837d42d3b5ca4783528b4e084548 (patch) | |
tree | ddcd142e73df4c90dc5d45c4a276e6c99bbf7147 /test | |
parent | 0cb9e1d021607723e008de877a056f2db2a32cef (diff) |
Internal change.
PiperOrigin-RevId: 310949277
Diffstat (limited to 'test')
-rw-r--r-- | test/packetimpact/tests/udp_icmp_error_propagation_test.go | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/test/packetimpact/tests/udp_icmp_error_propagation_test.go b/test/packetimpact/tests/udp_icmp_error_propagation_test.go index 30dcb336e..1462f360e 100644 --- a/test/packetimpact/tests/udp_icmp_error_propagation_test.go +++ b/test/packetimpact/tests/udp_icmp_error_propagation_test.go @@ -18,6 +18,7 @@ import ( "context" "fmt" "net" + "sync" "syscall" "testing" "time" @@ -300,19 +301,22 @@ func TestICMPErrorDuringUDPRecv(t *testing.T) { t.Fatalf("did not receive message from DUT: %s", err) } - c := make(chan error) - go func(c chan error) { + var wg sync.WaitGroup + wg.Add(2) + go func() { + defer wg.Done() + if wantErrno != syscall.Errno(0) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() ret, _, err := dut.RecvWithErrno(ctx, remoteFD, 100, 0) if ret != -1 { - c <- fmt.Errorf("recv during ICMP error succeeded unexpectedly, expected (%[1]d) %[1]v", wantErrno) + t.Errorf("recv during ICMP error succeeded unexpectedly, expected (%[1]d) %[1]v", wantErrno) return } if err != wantErrno { - c <- fmt.Errorf("recv during ICMP error resulted in error (%[1]d) %[1]v, expected (%[2]d) %[2]v", err, wantErrno) + t.Errorf("recv during ICMP error resulted in error (%[1]d) %[1]v, expected (%[2]d) %[2]v", err, wantErrno) return } } @@ -321,23 +325,20 @@ func TestICMPErrorDuringUDPRecv(t *testing.T) { defer cancel() if ret, _, err := dut.RecvWithErrno(ctx, remoteFD, 100, 0); ret == -1 { - c <- fmt.Errorf("recv after ICMP error failed with (%[1]d) %[1]", err) - return + t.Errorf("recv after ICMP error failed with (%[1]d) %[1]", err) } - c <- nil - }(c) + }() + + go func() { + defer wg.Done() - cleanChan := make(chan error) - go func(c chan error) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() if ret, _, err := dut.RecvWithErrno(ctx, cleanFD, 100, 0); ret == -1 { - c <- fmt.Errorf("recv on clean socket failed with (%[1]d) %[1]", err) - return + t.Errorf("recv on clean socket failed with (%[1]d) %[1]", err) } - c <- nil - }(cleanChan) + }() // TODO(b/155684889) This sleep is to allow time for the DUT to // actually call recv since we want the ICMP error to arrive during the @@ -351,14 +352,7 @@ func TestICMPErrorDuringUDPRecv(t *testing.T) { conn.Send(tb.UDP{DstPort: &cleanPort}) conn.Send(tb.UDP{}) - - err, errClean := <-c, <-cleanChan - if errClean != nil { - t.Error(err) - } - if err != nil { - t.Fatal(err) - } + wg.Wait() }) } } |