]> Cypherpunks repositories - gostls13.git/commitdiff
net: separate NaCl dependent placeholders from BSD's
authorMikio Hara <mikioh.mikioh@gmail.com>
Thu, 18 Sep 2014 10:17:55 +0000 (19:17 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Thu, 18 Sep 2014 10:17:55 +0000 (19:17 +0900)
To clarify the dependency of NaCl platform.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/143830044

23 files changed:
src/net/dial_test.go
src/net/dnsclient_unix.go
src/net/dnsconfig_unix.go
src/net/file_stub.go [new file with mode: 0644]
src/net/file_test.go
src/net/file_unix.go
src/net/ipraw_test.go
src/net/lookup_stub.go [new file with mode: 0644]
src/net/lookup_unix.go
src/net/port_test.go
src/net/port_unix.go
src/net/sock_bsd.go
src/net/sock_stub.go [moved from src/net/sock_solaris.go with 93% similarity]
src/net/sockopt_bsd.go
src/net/sockopt_posix.go
src/net/sockopt_stub.go [new file with mode: 0644]
src/net/sockoptip_bsd.go
src/net/sockoptip_posix.go
src/net/sockoptip_stub.go
src/net/tcpsockopt_openbsd.go [new file with mode: 0644]
src/net/tcpsockopt_posix.go
src/net/tcpsockopt_stub.go
src/os/exec/exec_test.go

index 19e289f2e5e842419cdaf68afdf524a6cc52746e..abeb50009810ec721264693af093aa313f2bb80b 100644 (file)
@@ -465,6 +465,11 @@ func TestDialer(t *testing.T) {
 }
 
 func TestDialDualStackLocalhost(t *testing.T) {
+       switch runtime.GOOS {
+       case "nacl":
+               t.Skipf("skipping test on %q", runtime.GOOS)
+       }
+
        if ips, err := LookupIP("localhost"); err != nil {
                t.Fatalf("LookupIP failed: %v", err)
        } else if len(ips) < 2 || !supportsIPv4 || !supportsIPv6 {
index abe7da05cb579e14fd27f17782528190224f0487..7511083f7955e6304230038893a8785853b90aaf 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
 
 // DNS client: see RFC 1035.
 // Has to be linked into package net for Dial.
index ebb6e673f1e53d345ca7f4280d221218f538055f..66ab7c4dd30d8e8bf4fd5a8cc0ecd09bde82663b 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
 
 // Read system DNS config from /etc/resolv.conf
 
diff --git a/src/net/file_stub.go b/src/net/file_stub.go
new file mode 100644 (file)
index 0000000..4281072
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build nacl
+
+package net
+
+import (
+       "os"
+       "syscall"
+)
+
+// FileConn returns a copy of the network connection corresponding to
+// the open file f.  It is the caller's responsibility to close f when
+// finished.  Closing c does not affect f, and closing f does not
+// affect c.
+func FileConn(f *os.File) (c Conn, err error) {
+       return nil, syscall.ENOPROTOOPT
+
+}
+
+// FileListener returns a copy of the network listener corresponding
+// to the open file f.  It is the caller's responsibility to close l
+// when finished.  Closing l does not affect f, and closing f does not
+// affect l.
+func FileListener(f *os.File) (l Listener, err error) {
+       return nil, syscall.ENOPROTOOPT
+
+}
+
+// FilePacketConn returns a copy of the packet network connection
+// corresponding to the open file f.  It is the caller's
+// responsibility to close f when finished.  Closing c does not affect
+// f, and closing f does not affect c.
+func FilePacketConn(f *os.File) (c PacketConn, err error) {
+       return nil, syscall.ENOPROTOOPT
+}
index d81bca78249472e4b001924604c64b84f7d5813d..6fab06a9c6e3de929c271d4d7fdf508b59767564 100644 (file)
@@ -89,7 +89,7 @@ var fileListenerTests = []struct {
 
 func TestFileListener(t *testing.T) {
        switch runtime.GOOS {
-       case "windows":
+       case "nacl", "windows":
                t.Skipf("skipping test on %q", runtime.GOOS)
        }
 
index 07b3ecf62637f44d726a674109f9fa01696974b6..214a4196c8e3cfca5376ab380ef7912c07e7de97 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
 
 package net
 
index 0632dafc65e642cfef1ab535386f224fb0600080..92dc8dc56942322c460833145ece5b2d7fa3a3c6 100644 (file)
@@ -68,6 +68,11 @@ func skipRawSocketTest(t *testing.T) (skip bool, skipmsg string) {
 }
 
 func TestResolveIPAddr(t *testing.T) {
+       switch runtime.GOOS {
+       case "nacl":
+               t.Skipf("skipping test on %q", runtime.GOOS)
+       }
+
        for _, tt := range resolveIPAddrTests {
                addr, err := ResolveIPAddr(tt.net, tt.litAddrOrName)
                if err != tt.err {
diff --git a/src/net/lookup_stub.go b/src/net/lookup_stub.go
new file mode 100644 (file)
index 0000000..502aafb
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright 2011 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build nacl
+
+package net
+
+import "syscall"
+
+func lookupProtocol(name string) (proto int, err error) {
+       return 0, syscall.ENOPROTOOPT
+}
+
+func lookupHost(host string) (addrs []string, err error) {
+       return nil, syscall.ENOPROTOOPT
+}
+
+func lookupIP(host string) (ips []IP, err error) {
+       return nil, syscall.ENOPROTOOPT
+}
+
+func lookupPort(network, service string) (port int, err error) {
+       return 0, syscall.ENOPROTOOPT
+}
+
+func lookupCNAME(name string) (cname string, err error) {
+       return "", syscall.ENOPROTOOPT
+}
+
+func lookupSRV(service, proto, name string) (cname string, srvs []*SRV, err error) {
+       return "", nil, syscall.ENOPROTOOPT
+}
+
+func lookupMX(name string) (mxs []*MX, err error) {
+       return nil, syscall.ENOPROTOOPT
+}
+
+func lookupNS(name string) (nss []*NS, err error) {
+       return nil, syscall.ENOPROTOOPT
+}
+
+func lookupTXT(name string) (txts []string, err error) {
+       return nil, syscall.ENOPROTOOPT
+}
+
+func lookupAddr(addr string) (ptrs []string, err error) {
+       return nil, syscall.ENOPROTOOPT
+}
index b1d2f8f31a9e6eea37a9659464e970e12699e6ff..a54578456d7c6ac49df2a0ae56460c90afaa3e0c 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
 
 package net
 
index 9e8968f359cdb60ffb30ab80d30da4e596e76362..4811ade69e090bf8ac07311f2c0cafd10291edb6 100644 (file)
@@ -5,6 +5,7 @@
 package net
 
 import (
+       "runtime"
        "testing"
 )
 
@@ -43,6 +44,11 @@ var porttests = []portTest{
 }
 
 func TestLookupPort(t *testing.T) {
+       switch runtime.GOOS {
+       case "nacl":
+               t.Skipf("skipping test on %q", runtime.GOOS)
+       }
+
        for i := 0; i < len(porttests); i++ {
                tt := porttests[i]
                if port, err := LookupPort(tt.netw, tt.name); port != tt.port || (err == nil) != tt.ok {
index 89558c1f029bc7221f6f54dad192a00e7c495ee4..348c771c3511ad0776c5690e4a90e1e1c95d5fec 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris
 
 // Read system port mappings from /etc/services
 
index 48fb7852757c23687f3445f96ce46248bb7a1eb7..6c37109f5e4b02d84924719372e957bfb357bb13 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd nacl netbsd openbsd
+// +build darwin dragonfly freebsd netbsd openbsd
 
 package net
 
similarity index 93%
rename from src/net/sock_solaris.go
rename to src/net/sock_stub.go
index 90fe9de894cd0522937d65a4dd1cc561bcce6c2d..ed6b08948931229a5aa426c8ef173364e841e414 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build nacl solaris
+
 package net
 
 import "syscall"
index 2d36a559534a5cdf90402996335af9765a7039dc..00e4dbf3761102994b2445ff6a05afa0b41670e7 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd nacl netbsd openbsd
+// +build darwin dragonfly freebsd netbsd openbsd
 
 package net
 
index 921918c37f543b42dbb17569d82c3e2b2fcc45b5..1654d1b85e46c6481e0b7ebb5c009b3e205faa0f 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
 
 package net
 
diff --git a/src/net/sockopt_stub.go b/src/net/sockopt_stub.go
new file mode 100644 (file)
index 0000000..de5ee0b
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright 2011 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build nacl
+
+package net
+
+import "syscall"
+
+func setDefaultSockopts(s, family, sotype int, ipv6only bool) error {
+       return nil
+}
+
+func setDefaultListenerSockopts(s int) error {
+       return nil
+}
+
+func setDefaultMulticastSockopts(s int) error {
+       return nil
+}
+
+func setReadBuffer(fd *netFD, bytes int) error {
+       return syscall.ENOPROTOOPT
+}
+
+func setWriteBuffer(fd *netFD, bytes int) error {
+       return syscall.ENOPROTOOPT
+}
+
+func setKeepAlive(fd *netFD, keepalive bool) error {
+       return syscall.ENOPROTOOPT
+}
+
+func setLinger(fd *netFD, sec int) error {
+       return syscall.ENOPROTOOPT
+}
index 87132f0f4610cc3ee9700d2896b48fdf40723c4c..2199e480d423bd5c167d8ff2f3212111b298bf8e 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd nacl netbsd openbsd
+// +build darwin dragonfly freebsd netbsd openbsd
 
 package net
 
index b5c80e4490996609c002c1e6de86325d007fa5af..c2579be9114fa4796ebaf7acbe07f542ca20d30d 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux nacl netbsd openbsd windows
+// +build darwin dragonfly freebsd linux netbsd openbsd windows
 
 package net
 
index dcd3a22b57deb60e34abac8c73ffe2df6d58c1bb..32ec5ddb85908532e79e2448dfb00477f5eb1f61 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build solaris
+// +build nacl solaris
 
 package net
 
@@ -10,30 +10,30 @@ import "syscall"
 
 func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error {
        // See golang.org/issue/7399.
-       return syscall.EINVAL
+       return syscall.ENOPROTOOPT
 }
 
 func setIPv4MulticastLoopback(fd *netFD, v bool) error {
        // See golang.org/issue/7399.
-       return syscall.EINVAL
+       return syscall.ENOPROTOOPT
 }
 
 func joinIPv4Group(fd *netFD, ifi *Interface, ip IP) error {
        // See golang.org/issue/7399.
-       return syscall.EINVAL
+       return syscall.ENOPROTOOPT
 }
 
 func setIPv6MulticastInterface(fd *netFD, ifi *Interface) error {
        // See golang.org/issue/7399.
-       return syscall.EINVAL
+       return syscall.ENOPROTOOPT
 }
 
 func setIPv6MulticastLoopback(fd *netFD, v bool) error {
        // See golang.org/issue/7399.
-       return syscall.EINVAL
+       return syscall.ENOPROTOOPT
 }
 
 func joinIPv6Group(fd *netFD, ifi *Interface, ip IP) error {
        // See golang.org/issue/7399.
-       return syscall.EINVAL
+       return syscall.ENOPROTOOPT
 }
diff --git a/src/net/tcpsockopt_openbsd.go b/src/net/tcpsockopt_openbsd.go
new file mode 100644 (file)
index 0000000..041e178
--- /dev/null
@@ -0,0 +1,16 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package net
+
+import (
+       "syscall"
+       "time"
+)
+
+func setKeepAlivePeriod(fd *netFD, d time.Duration) error {
+       // OpenBSD has no user-settable per-socket TCP keepalive
+       // options.
+       return syscall.ENOPROTOOPT
+}
index 6484bad4b45d6f3a4856095cd8a0f42e8cc1a2e4..0abf3f97f6b4e028f5ddfa0c792b951140453d1a 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
+// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
 
 package net
 
index 346293ca46f3602d67ce9fbb3f44e00f0d13c00d..b413a764d8279cf0bfc888919b1ed78b01f97de7 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build nacl openbsd
+// +build nacl
 
 package net
 
@@ -11,8 +11,10 @@ import (
        "time"
 )
 
+func setNoDelay(fd *netFD, noDelay bool) error {
+       return syscall.ENOPROTOOPT
+}
+
 func setKeepAlivePeriod(fd *netFD, d time.Duration) error {
-       // NaCl and OpenBSD have no user-settable per-socket TCP
-       // keepalive options.
        return syscall.ENOPROTOOPT
 }
index 6f77ac38aebd6571bb1e61737bbddc5ab0d5ec6b..5fd439b8bb297c5e0b5fd463ea409c07d4e60a18 100644 (file)
@@ -383,8 +383,9 @@ func TestExtraFilesFDShuffle(t *testing.T) {
 }
 
 func TestExtraFiles(t *testing.T) {
-       if runtime.GOOS == "windows" {
-               t.Skip("no operating system support; skipping")
+       switch runtime.GOOS {
+       case "nacl", "windows":
+               t.Skipf("skipping test on %q", runtime.GOOS)
        }
 
        // Ensure that file descriptors have not already been leaked into