summaryrefslogtreecommitdiffhomepage
path: root/test/packetimpact/tests
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-05-07 12:08:45 -0700
committergVisor bot <gvisor-bot@google.com>2020-05-07 12:10:02 -0700
commit92cab8e2c388900f687b5ee861e82739a2d5f2c2 (patch)
treecf127c0107d1b1fa56a1548b66114ee06fb6dc2c /test/packetimpact/tests
parent26c60d7d5d31fdf3ad380a0f09b4f33afae3d9d3 (diff)
Internal change.
PiperOrigin-RevId: 310409922
Diffstat (limited to 'test/packetimpact/tests')
-rw-r--r--test/packetimpact/tests/udp_icmp_error_propagation_test.go38
1 files changed, 24 insertions, 14 deletions
diff --git a/test/packetimpact/tests/udp_icmp_error_propagation_test.go b/test/packetimpact/tests/udp_icmp_error_propagation_test.go
index c47af9a3e..30dcb336e 100644
--- a/test/packetimpact/tests/udp_icmp_error_propagation_test.go
+++ b/test/packetimpact/tests/udp_icmp_error_propagation_test.go
@@ -18,7 +18,6 @@ import (
"context"
"fmt"
"net"
- "sync"
"syscall"
"testing"
"time"
@@ -301,19 +300,20 @@ func TestICMPErrorDuringUDPRecv(t *testing.T) {
t.Fatalf("did not receive message from DUT: %s", err)
}
- var wg sync.WaitGroup
- wg.Add(2)
- go func() {
+ c := make(chan error)
+ go func(c chan error) {
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 {
- t.Fatalf("recv during ICMP error succeeded unexpectedly, expected (%[1]d) %[1]v", wantErrno)
+ c <- fmt.Errorf("recv during ICMP error succeeded unexpectedly, expected (%[1]d) %[1]v", wantErrno)
+ return
}
if err != wantErrno {
- t.Fatalf("recv during ICMP error resulted in error (%[1]d) %[1]v, expected (%[2]d) %[2]v", err, wantErrno)
+ c <- fmt.Errorf("recv during ICMP error resulted in error (%[1]d) %[1]v, expected (%[2]d) %[2]v", err, wantErrno)
+ return
}
}
@@ -321,20 +321,23 @@ func TestICMPErrorDuringUDPRecv(t *testing.T) {
defer cancel()
if ret, _, err := dut.RecvWithErrno(ctx, remoteFD, 100, 0); ret == -1 {
- t.Fatalf("recv after ICMP error failed with (%[1]d) %[1]", err)
+ c <- fmt.Errorf("recv after ICMP error failed with (%[1]d) %[1]", err)
+ return
}
- wg.Done()
- }()
+ c <- nil
+ }(c)
- go func() {
+ 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 {
- t.Fatalf("recv on clean socket failed with (%[1]d) %[1]", err)
+ c <- fmt.Errorf("recv on clean socket failed with (%[1]d) %[1]", err)
+ return
}
- wg.Done()
- }()
+ 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
@@ -348,7 +351,14 @@ func TestICMPErrorDuringUDPRecv(t *testing.T) {
conn.Send(tb.UDP{DstPort: &cleanPort})
conn.Send(tb.UDP{})
- wg.Wait()
+
+ err, errClean := <-c, <-cleanChan
+ if errClean != nil {
+ t.Error(err)
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
})
}
}