]> Cypherpunks repositories - gostls13.git/commitdiff
net: disable tests for functions not available on windows
authorAlex Brainman <alex.brainman@gmail.com>
Sun, 12 Sep 2010 02:02:29 +0000 (12:02 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Sun, 12 Sep 2010 02:02:29 +0000 (12:02 +1000)
R=r, Joe Poirier, rsc
CC=golang-dev
https://golang.org/cl/2123044

src/pkg/Makefile
src/pkg/net/parse_test.go
src/pkg/net/port_test.go
src/pkg/net/server_test.go
src/pkg/net/timeout_test.go
src/pkg/syscall/syscall_windows.go

index b8e45da407b62b39ee4e66417c5e2074e0849253..3a6491a924c6b22160d5bb5b0edacc68b4f69c42 100644 (file)
@@ -190,7 +190,6 @@ endif
 ifeq ($(GOOS),windows)
 NOTEST+=exec         # no pipe
 NOTEST+=log          # no runtime.Caller
-NOTEST+=net          # no network
 NOTEST+=os           # many things unimplemented
 NOTEST+=os/signal    # no signals
 NOTEST+=path         # tree walking does not work
index f53df3b6832201ce966c903a799959711e8e8888..2b7784eee2d24bfef3a7a2f454f59f9cec9d91cb 100644 (file)
@@ -8,9 +8,14 @@ import (
        "bufio"
        "os"
        "testing"
+       "runtime"
 )
 
 func TestReadLine(t *testing.T) {
+       // /etc/services file does not exist on windows.
+       if runtime.GOOS == "windows" {
+               return
+       }
        filename := "/etc/services" // a nice big file
 
        fd, err := os.Open(filename, os.O_RDONLY, 0)
index 50aab5aba70b510ecc39951837c385e0849f9386..7a796a874c127b0f656c0b2bd9f46e81ab5cd1cc 100644 (file)
@@ -23,7 +23,6 @@ var porttests = []portTest{
        portTest{"tcp", "chargen", 19, true},
        portTest{"tcp", "ftp-data", 20, true},
        portTest{"tcp", "ftp", 21, true},
-       portTest{"tcp", "ssh", 22, true},
        portTest{"tcp", "telnet", 23, true},
        portTest{"tcp", "smtp", 25, true},
        portTest{"tcp", "time", 37, true},
index 0d077fe95f4e2c69c574113a61e3e21082a85626..46bedaa5bcbb8b850c1cee0a8a0f6aaee234e392 100644 (file)
@@ -11,6 +11,7 @@ import (
        "strings"
        "syscall"
        "testing"
+       "runtime"
 )
 
 // Do not test empty datagrams by default.
@@ -108,6 +109,10 @@ func TestTCPServer(t *testing.T) {
 }
 
 func TestUnixServer(t *testing.T) {
+       // "unix" sockets are not supported on windows.
+       if runtime.GOOS == "windows" {
+               return
+       }
        os.Remove("/tmp/gotest.net")
        doTest(t, "unix", "/tmp/gotest.net", "/tmp/gotest.net")
        os.Remove("/tmp/gotest.net")
@@ -177,6 +182,10 @@ func TestUDPServer(t *testing.T) {
 }
 
 func TestUnixDatagramServer(t *testing.T) {
+       // "unix" sockets are not supported on windows.
+       if runtime.GOOS == "windows" {
+               return
+       }
        for _, isEmpty := range []bool{false} {
                os.Remove("/tmp/gotest1.net")
                os.Remove("/tmp/gotest1.net.local")
index 3594c0a350fff159f95fc9cb3d059a6064cd703d..092781685e1bb2706c099047d13f0240a0029b35 100644 (file)
@@ -8,9 +8,14 @@ import (
        "os"
        "testing"
        "time"
+       "runtime"
 )
 
 func testTimeout(t *testing.T, network, addr string, readFrom bool) {
+       // Timeouts are not implemented on windows.
+       if runtime.GOOS == "windows" {
+               return
+       }
        fd, err := Dial(network, "", addr)
        if err != nil {
                t.Errorf("dial %s %s failed: %v", network, addr, err)
index 62990440b50e47f8a4a0881851bae0c047a37b37..3eb0af16db0b85ba56c0d74dce419793e85e6e99 100644 (file)
@@ -442,6 +442,9 @@ func Utimes(path string, tv []Timeval) (errno int) {
 //sys  DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status uint32) = dnsapi.DnsQuery_W
 //sys  DnsRecordListFree(rl *DNSRecord, freetype uint32) = dnsapi.DnsRecordListFree
 
+// For testing: clients can set this flag to force
+// creation of IPv6 sockets to return EAFNOSUPPORT.
+var SocketDisableIPv6 bool
 
 type RawSockaddrInet4 struct {
        Family uint16
@@ -525,6 +528,9 @@ func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, int) {
 }
 
 func Socket(domain, typ, proto int) (fd, errno int) {
+       if domain == AF_INET6 && SocketDisableIPv6 {
+               return -1, EAFNOSUPPORT
+       }
        h, e := socket(int32(domain), int32(typ), int32(proto))
        return int(h), int(e)
 }