mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Fix nogo test in //pkg/tcpip/...
PiperOrigin-RevId: 338168977
This commit is contained in:
@@ -97,6 +97,9 @@ type testConnection struct {
|
||||
func connect(s *stack.Stack, addr tcpip.FullAddress) (*testConnection, *tcpip.Error) {
|
||||
wq := &waiter.Queue{}
|
||||
ep, err := s.NewEndpoint(tcp.ProtocolNumber, ipv4.ProtocolNumber, wq)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
entry, ch := waiter.NewChannelEntry(nil)
|
||||
wq.EventRegister(&entry, waiter.EventOut)
|
||||
@@ -145,7 +148,9 @@ func TestCloseReader(t *testing.T) {
|
||||
defer close(done)
|
||||
c, err := l.Accept()
|
||||
if err != nil {
|
||||
t.Fatalf("l.Accept() = %v", err)
|
||||
t.Errorf("l.Accept() = %v", err)
|
||||
// Cannot call Fatalf in goroutine. Just return from the goroutine.
|
||||
return
|
||||
}
|
||||
|
||||
// Give c.Read() a chance to block before closing the connection.
|
||||
@@ -416,7 +421,9 @@ func TestDeadlineChange(t *testing.T) {
|
||||
defer close(done)
|
||||
c, err := l.Accept()
|
||||
if err != nil {
|
||||
t.Fatalf("l.Accept() = %v", err)
|
||||
t.Errorf("l.Accept() = %v", err)
|
||||
// Cannot call Fatalf in goroutine. Just return from the goroutine.
|
||||
return
|
||||
}
|
||||
|
||||
c.SetDeadline(time.Now().Add(time.Minute))
|
||||
|
||||
@@ -470,6 +470,7 @@ func TestConcurrentReaderWriter(t *testing.T) {
|
||||
|
||||
const count = 1000000
|
||||
var wg sync.WaitGroup
|
||||
defer wg.Wait()
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
@@ -489,30 +490,23 @@ func TestConcurrentReaderWriter(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
runtime.Gosched()
|
||||
for i := 0; i < count; i++ {
|
||||
n := 1 + rr.Intn(80)
|
||||
rb := rx.Pull()
|
||||
for rb == nil {
|
||||
rb = rx.Pull()
|
||||
}
|
||||
|
||||
if n != len(rb) {
|
||||
t.Fatalf("Bad %v-th buffer length: got %v, want %v", i, len(rb), n)
|
||||
}
|
||||
|
||||
for j := range rb {
|
||||
if v := byte(rr.Intn(256)); v != rb[j] {
|
||||
t.Fatalf("Bad %v-th read buffer at index %v: got %v, want %v", i, j, rb[j], v)
|
||||
}
|
||||
}
|
||||
|
||||
rx.Flush()
|
||||
for i := 0; i < count; i++ {
|
||||
n := 1 + rr.Intn(80)
|
||||
rb := rx.Pull()
|
||||
for rb == nil {
|
||||
rb = rx.Pull()
|
||||
}
|
||||
}()
|
||||
|
||||
wg.Wait()
|
||||
if n != len(rb) {
|
||||
t.Fatalf("Bad %v-th buffer length: got %v, want %v", i, len(rb), n)
|
||||
}
|
||||
|
||||
for j := range rb {
|
||||
if v := byte(rr.Intn(256)); v != rb[j] {
|
||||
t.Fatalf("Bad %v-th read buffer at index %v: got %v, want %v", i, j, rb[j], v)
|
||||
}
|
||||
}
|
||||
|
||||
rx.Flush()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ func (s *SACKScoreboard) IsSACKED(r header.SACKBlock) bool {
|
||||
return found
|
||||
}
|
||||
|
||||
// Dump prints the state of the scoreboard structure.
|
||||
// String returns human-readable state of the scoreboard structure.
|
||||
func (s *SACKScoreboard) String() string {
|
||||
var str strings.Builder
|
||||
str.WriteString("SACKScoreboard: {")
|
||||
|
||||
@@ -481,21 +481,6 @@ func init() {
|
||||
"pkg/state/tests/integer_test.go:28",
|
||||
"pkg/sync/rwmutex_test.go:105",
|
||||
"pkg/syserr/host_linux.go:35",
|
||||
"pkg/tcpip/adapters/gonet/gonet_test.go:144",
|
||||
"pkg/tcpip/adapters/gonet/gonet_test.go:415",
|
||||
"pkg/tcpip/adapters/gonet/gonet_test.go:99",
|
||||
"pkg/tcpip/buffer/view.go:238",
|
||||
"pkg/tcpip/buffer/view.go:238",
|
||||
"pkg/tcpip/buffer/view.go:246",
|
||||
"pkg/tcpip/header/tcp.go:151",
|
||||
"pkg/tcpip/link/sharedmem/pipe/pipe_test.go:493",
|
||||
"pkg/tcpip/stack/iptables.go:293",
|
||||
"pkg/tcpip/stack/iptables_types.go:277",
|
||||
"pkg/tcpip/stack/stack.go:553",
|
||||
"pkg/tcpip/stack/transport_test.go:30",
|
||||
"pkg/tcpip/transport/packet/endpoint.go:126",
|
||||
"pkg/tcpip/transport/raw/endpoint.go:145",
|
||||
"pkg/tcpip/transport/tcp/sack_scoreboard.go:167",
|
||||
"pkg/unet/unet_test.go:634",
|
||||
"pkg/unet/unet_test.go:662",
|
||||
"pkg/unet/unet_test.go:703",
|
||||
|
||||
Reference in New Issue
Block a user