mirror of
https://github.com/golang/go
synced 2024-11-23 04:00:03 -07:00
net: deflake TestLookupPort on Android
Looks like some version of Android still fails with "servname not supported for ai_socktype". It probably doesn't support ai_socktype=SOCK_STREAM. Updates #14576. Change-Id: I77ecff147d5b759e3281b3798c60f150a4aab811 Reviewed-on: https://go-review.googlesource.com/23194 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
cdcb8271a4
commit
6de34e6e25
@ -598,41 +598,40 @@ func srvString(srvs []*SRV) string {
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
var lookupPortTests = []struct {
|
||||
network string
|
||||
name string
|
||||
port int
|
||||
ok bool
|
||||
}{
|
||||
func TestLookupPort(t *testing.T) {
|
||||
// See http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
|
||||
//
|
||||
// Please be careful about adding new mappings for testings.
|
||||
// There are platforms having incomplete mappings for
|
||||
// restricted resource access and security reasons.
|
||||
type test struct {
|
||||
network string
|
||||
name string
|
||||
port int
|
||||
ok bool
|
||||
}
|
||||
var tests = []test{
|
||||
{"tcp", "0", 0, true},
|
||||
{"udp", "0", 0, true},
|
||||
{"udp", "domain", 53, true},
|
||||
|
||||
{"tcp", "0", 0, true},
|
||||
{"tcp", "http", 80, true},
|
||||
{"udp", "0", 0, true},
|
||||
{"udp", "domain", 53, true},
|
||||
{"--badnet--", "zzz", 0, false},
|
||||
{"tcp", "--badport--", 0, false},
|
||||
{"tcp", "-1", 0, false},
|
||||
{"tcp", "65536", 0, false},
|
||||
{"udp", "-1", 0, false},
|
||||
{"udp", "65536", 0, false},
|
||||
{"tcp", "123456789", 0, false},
|
||||
|
||||
{"--badnet--", "zzz", 0, false},
|
||||
{"tcp", "--badport--", 0, false},
|
||||
{"tcp", "-1", 0, false},
|
||||
{"tcp", "65536", 0, false},
|
||||
{"udp", "-1", 0, false},
|
||||
{"udp", "65536", 0, false},
|
||||
{"tcp", "123456789", 0, false},
|
||||
// Issue 13610: LookupPort("tcp", "")
|
||||
{"tcp", "", 0, true},
|
||||
{"tcp4", "", 0, true},
|
||||
{"tcp6", "", 0, true},
|
||||
{"udp", "", 0, true},
|
||||
{"udp4", "", 0, true},
|
||||
{"udp6", "", 0, true},
|
||||
}
|
||||
|
||||
// Issue 13610: LookupPort("tcp", "")
|
||||
{"tcp", "", 0, true},
|
||||
{"tcp4", "", 0, true},
|
||||
{"tcp6", "", 0, true},
|
||||
{"udp", "", 0, true},
|
||||
{"udp4", "", 0, true},
|
||||
{"udp6", "", 0, true},
|
||||
}
|
||||
|
||||
func TestLookupPort(t *testing.T) {
|
||||
switch runtime.GOOS {
|
||||
case "nacl":
|
||||
t.Skipf("not supported on %s", runtime.GOOS)
|
||||
@ -640,9 +639,11 @@ func TestLookupPort(t *testing.T) {
|
||||
if netGo {
|
||||
t.Skipf("not supported on %s without cgo; see golang.org/issues/14576", runtime.GOOS)
|
||||
}
|
||||
default:
|
||||
tests = append(tests, test{"tcp", "http", 80, true})
|
||||
}
|
||||
|
||||
for _, tt := range lookupPortTests {
|
||||
for _, tt := range tests {
|
||||
port, err := LookupPort(tt.network, tt.name)
|
||||
if port != tt.port || (err == nil) != tt.ok {
|
||||
t.Errorf("LookupPort(%q, %q) = %d, %v; want %d, error=%t", tt.network, tt.name, port, err, tt.port, !tt.ok)
|
||||
|
Loading…
Reference in New Issue
Block a user