TUN-4060: Fix Go Vet warnings (new with go 1.16) where t.Fatalf is called from a test goroutine

This commit is contained in:
Nuno Diegues 2021-03-16 14:47:57 +00:00
parent d67fbbf94f
commit 8432735867
3 changed files with 8 additions and 4 deletions

View File

@ -81,7 +81,8 @@ func TestStartServer(t *testing.T) {
go func() { go func() {
err := Serve(wsConn, listener, shutdownC, options) err := Serve(wsConn, listener, shutdownC, options)
if err != nil { if err != nil {
t.Fatalf("Error running server: %v", err) t.Errorf("Error running server: %v", err)
return
} }
}() }()

View File

@ -663,7 +663,8 @@ func AssertIfPipeReadable(t *testing.T, pipe io.ReadCloser) {
b := []byte{0} b := []byte{0}
n, err := pipe.Read(b) n, err := pipe.Read(b)
if n > 0 { if n > 0 {
t.Fatalf("read pipe was not empty") t.Errorf("read pipe was not empty")
return
} }
errC <- err errC <- err
}() }()

View File

@ -81,7 +81,8 @@ func TestSharedBufferConcurrentReadWrite(t *testing.T) {
expectedResult.Write(block[:blockSize]) expectedResult.Write(block[:blockSize])
n, err := b.Write(block[:blockSize]) n, err := b.Write(block[:blockSize])
if n != blockSize || err != nil { if n != blockSize || err != nil {
t.Fatalf("write error: %d %s", n, err) t.Errorf("write error: %d %s", n, err)
return
} }
} }
} }
@ -94,7 +95,8 @@ func TestSharedBufferConcurrentReadWrite(t *testing.T) {
for i := 0; i < 256; i++ { for i := 0; i < 256; i++ {
n, err := io.ReadFull(b, block[:blockSize]) n, err := io.ReadFull(b, block[:blockSize])
if n != blockSize || err != nil { if n != blockSize || err != nil {
t.Fatalf("read error: %d %s", n, err) t.Errorf("read error: %d %s", n, err)
return
} }
actualResult.Write(block[:blockSize]) actualResult.Write(block[:blockSize])
} }