mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
gonet: fix test flaking
It's valid for Read() to return one of two errors. The test really just wants
to ensure we unblock.
Tested via:
$ bazel test //pkg/tcpip/adapters/gonet:gonet_test \
--test_filter TestCloseStack --runs_per_test=10000
Fixes #8748.
PiperOrigin-RevId: 525798649
This commit is contained in:
committed by
gVisor bot
parent
6a4840efff
commit
70da408248
@@ -402,15 +402,17 @@ func TestCloseStack(t *testing.T) {
|
||||
c := NewTCPConn(&wq, ep)
|
||||
|
||||
// Give c.Read() a chance to block before closing the stack.
|
||||
time.AfterFunc(time.Second*1, func() {
|
||||
time.AfterFunc(50*time.Millisecond, func() {
|
||||
s.Close()
|
||||
s.Wait()
|
||||
})
|
||||
|
||||
buf := make([]byte, 256)
|
||||
n, e := c.Read(buf)
|
||||
if n != 0 || !strings.Contains(e.Error(), "operation aborted") {
|
||||
t.Errorf("c.Read() = (%d, %v), want (0, operation aborted)", n, e)
|
||||
// Depending on the ordering of Close and Read, we should get
|
||||
// one of two errors.
|
||||
if n != 0 || (!strings.Contains(e.Error(), "operation aborted") && !strings.Contains(e.Error(), "connection reset by peer")) {
|
||||
t.Errorf("c.Read() = (%d, %v), want (0, operation aborted) or (0, connection reset by peer)", n, e)
|
||||
}
|
||||
})
|
||||
s.SetTransportProtocolHandler(tcp.ProtocolNumber, fwd.HandlePacket)
|
||||
|
||||
Reference in New Issue
Block a user