1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build !plan9 6 7 package net 8 9 import ( 10 "os" 11 "syscall" 12 "testing" 13 ) 14 15 var ( 16 errTimedout = syscall.ETIMEDOUT 17 errOpNotSupported = syscall.EOPNOTSUPP 18 ) 19 20 func isPlatformError(err error) bool { 21 _, ok := err.(syscall.Errno) 22 return ok 23 } 24 25 func TestSpuriousENOTAVAIL(t *testing.T) { 26 for _, tt := range []struct { 27 error 28 ok bool 29 }{ 30 {syscall.EADDRNOTAVAIL, true}, 31 {&os.SyscallError{Syscall: "syscall", Err: syscall.EADDRNOTAVAIL}, true}, 32 {&OpError{Op: "op", Err: syscall.EADDRNOTAVAIL}, true}, 33 {&OpError{Op: "op", Err: &os.SyscallError{Syscall: "syscall", Err: syscall.EADDRNOTAVAIL}}, true}, 34 35 {syscall.EINVAL, false}, 36 {&os.SyscallError{Syscall: "syscall", Err: syscall.EINVAL}, false}, 37 {&OpError{Op: "op", Err: syscall.EINVAL}, false}, 38 {&OpError{Op: "op", Err: &os.SyscallError{Syscall: "syscall", Err: syscall.EINVAL}}, false}, 39 } { 40 if ok := spuriousENOTAVAIL(tt.error); ok != tt.ok { 41 t.Errorf("spuriousENOTAVAIL(%v) = %v; want %v", tt.error, ok, tt.ok) 42 } 43 } 44 } 45