aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/net/error_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/net/error_test.go')
-rw-r--r--libgo/go/net/error_test.go33
1 files changed, 19 insertions, 14 deletions
diff --git a/libgo/go/net/error_test.go b/libgo/go/net/error_test.go
index 8d4a7ff..556eb8c 100644
--- a/libgo/go/net/error_test.go
+++ b/libgo/go/net/error_test.go
@@ -8,10 +8,11 @@ package net
import (
"context"
+ "errors"
"fmt"
"internal/poll"
"io"
- "io/ioutil"
+ "io/fs"
"net/internal/socktest"
"os"
"runtime"
@@ -96,12 +97,12 @@ second:
case *os.SyscallError:
nestedErr = err.Err
goto third
- case *os.PathError: // for Plan 9
+ case *fs.PathError: // for Plan 9
nestedErr = err.Err
goto third
}
switch nestedErr {
- case errCanceled, poll.ErrNetClosing, errMissingAddress, errNoSuitableAddress,
+ case errCanceled, ErrClosed, errMissingAddress, errNoSuitableAddress,
context.DeadlineExceeded, context.Canceled:
return nil
}
@@ -436,7 +437,7 @@ second:
goto third
}
switch nestedErr {
- case poll.ErrNetClosing, errTimeout, poll.ErrNotPollable, os.ErrDeadlineExceeded:
+ case ErrClosed, errTimeout, poll.ErrNotPollable, os.ErrDeadlineExceeded:
return nil
}
return fmt.Errorf("unexpected type on 2nd nested level: %T", nestedErr)
@@ -478,7 +479,7 @@ second:
goto third
}
switch nestedErr {
- case errCanceled, poll.ErrNetClosing, errMissingAddress, errTimeout, os.ErrDeadlineExceeded, ErrWriteToConnected, io.ErrUnexpectedEOF:
+ case errCanceled, ErrClosed, errMissingAddress, errTimeout, os.ErrDeadlineExceeded, ErrWriteToConnected, io.ErrUnexpectedEOF:
return nil
}
return fmt.Errorf("unexpected type on 2nd nested level: %T", nestedErr)
@@ -508,6 +509,10 @@ func parseCloseError(nestedErr error, isShutdown bool) error {
return fmt.Errorf("error string %q does not contain expected string %q", nestedErr, want)
}
+ if !isShutdown && !errors.Is(nestedErr, ErrClosed) {
+ return fmt.Errorf("errors.Is(%v, errClosed) returns false, want true", nestedErr)
+ }
+
switch err := nestedErr.(type) {
case *OpError:
if err := err.isValid(); err != nil {
@@ -526,12 +531,12 @@ second:
case *os.SyscallError:
nestedErr = err.Err
goto third
- case *os.PathError: // for Plan 9
+ case *fs.PathError: // for Plan 9
nestedErr = err.Err
goto third
}
switch nestedErr {
- case poll.ErrNetClosing:
+ case ErrClosed:
return nil
}
return fmt.Errorf("unexpected type on 2nd nested level: %T", nestedErr)
@@ -541,7 +546,7 @@ third:
return nil
}
switch nestedErr {
- case os.ErrClosed: // for Plan 9
+ case fs.ErrClosed: // for Plan 9
return nil
}
return fmt.Errorf("unexpected type on 3rd nested level: %T", nestedErr)
@@ -622,12 +627,12 @@ second:
case *os.SyscallError:
nestedErr = err.Err
goto third
- case *os.PathError: // for Plan 9
+ case *fs.PathError: // for Plan 9
nestedErr = err.Err
goto third
}
switch nestedErr {
- case poll.ErrNetClosing, errTimeout, poll.ErrNotPollable, os.ErrDeadlineExceeded:
+ case ErrClosed, errTimeout, poll.ErrNotPollable, os.ErrDeadlineExceeded:
return nil
}
return fmt.Errorf("unexpected type on 2nd nested level: %T", nestedErr)
@@ -701,12 +706,12 @@ second:
case *os.LinkError:
nestedErr = err.Err
goto third
- case *os.PathError:
+ case *fs.PathError:
nestedErr = err.Err
goto third
}
switch nestedErr {
- case poll.ErrNetClosing:
+ case ErrClosed:
return nil
}
return fmt.Errorf("unexpected type on 2nd nested level: %T", nestedErr)
@@ -724,7 +729,7 @@ func TestFileError(t *testing.T) {
t.Skipf("not supported on %s", runtime.GOOS)
}
- f, err := ioutil.TempFile("", "go-nettest")
+ f, err := os.CreateTemp("", "go-nettest")
if err != nil {
t.Fatal(err)
}
@@ -794,7 +799,7 @@ func parseLookupPortError(nestedErr error) error {
switch nestedErr.(type) {
case *AddrError, *DNSError:
return nil
- case *os.PathError: // for Plan 9
+ case *fs.PathError: // for Plan 9
return nil
}
return fmt.Errorf("unexpected type on 1st nested level: %T", nestedErr)