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:
Mikio Hara 2015-04-28 21:17:46 +09:00
parent e64764c8d0
commit 98e0556231
6 changed files with 704 additions and 635 deletions

View file

@ -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: