mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net: deflake timeout, deadline tests
This change deflakes timeout, deadline tests, especially fixes socket and goroutine leaks. Also adds a few missing tests that use features introduced after go1 release. Change-Id: Ibf73a4859f8d4a0ee494ca2fd180cbce72a7a2c7 Reviewed-on: https://go-review.googlesource.com/9464 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
e64764c8d0
commit
98e0556231
6 changed files with 704 additions and 635 deletions
|
|
@ -15,16 +15,6 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
func isTimeoutError(err error) bool {
|
||||
nerr, ok := err.(Error)
|
||||
return ok && nerr.Timeout()
|
||||
}
|
||||
|
||||
func isTemporaryError(err error) bool {
|
||||
nerr, ok := err.(Error)
|
||||
return ok && nerr.Temporary()
|
||||
}
|
||||
|
||||
func (e *OpError) isValid() error {
|
||||
if e.Op == "" {
|
||||
return fmt.Errorf("OpError.Op is empty: %v", e)
|
||||
|
|
@ -467,7 +457,7 @@ func TestAcceptError(t *testing.T) {
|
|||
if c != nil {
|
||||
t.Errorf("Accept returned non-nil interface %T(%v) with err != nil", c, c)
|
||||
}
|
||||
if !isTimeoutError(err) && !isTemporaryError(err) {
|
||||
if nerr, ok := err.(Error); !ok || (!nerr.Timeout() && !nerr.Temporary()) {
|
||||
return
|
||||
}
|
||||
continue
|
||||
|
|
@ -521,6 +511,10 @@ second:
|
|||
nestedErr = err.Err
|
||||
goto third
|
||||
}
|
||||
switch nestedErr {
|
||||
case errClosing:
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unexpected type on 2nd nested level: %T", nestedErr)
|
||||
|
||||
third:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue