1
0
mirror of https://github.com/golang/go synced 2024-11-23 07:30:05 -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:
Mikio Hara 2016-05-18 10:54:20 +09:00
parent cdcb8271a4
commit 6de34e6e25

View File

@ -598,20 +598,20 @@ 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},
{"tcp", "http", 80, true},
{"udp", "0", 0, true},
{"udp", "domain", 53, true},
@ -632,7 +632,6 @@ var lookupPortTests = []struct {
{"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)