diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-06 19:49:01 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-06 19:49:01 +0000 |
commit | 0ce10ea1348e9afd5d0eec6bca986bfe58bac5ac (patch) | |
tree | 39530b071991b2326f881b2a30a2d82d6c133fd6 /libgo/go/net/net_test.go | |
parent | 57a8bf1b0c6057ccbacb0cf79eb84d1985c2c1fe (diff) | |
download | gcc-0ce10ea1348e9afd5d0eec6bca986bfe58bac5ac.tar.gz |
libgo: Update to October 24 version of master library.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204466 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/net/net_test.go')
-rw-r--r-- | libgo/go/net/net_test.go | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/libgo/go/net/net_test.go b/libgo/go/net/net_test.go index 1a512a5b110..1320096df8f 100644 --- a/libgo/go/net/net_test.go +++ b/libgo/go/net/net_test.go @@ -25,6 +25,7 @@ func TestShutdown(t *testing.T) { } go func() { + defer ln.Close() c, err := ln.Accept() if err != nil { t.Fatalf("Accept: %v", err) @@ -75,7 +76,10 @@ func TestShutdownUnix(t *testing.T) { if err != nil { t.Fatalf("ListenUnix on %s: %s", tmpname, err) } - defer os.Remove(tmpname) + defer func() { + ln.Close() + os.Remove(tmpname) + }() go func() { c, err := ln.Accept() @@ -214,3 +218,41 @@ func TestTCPClose(t *testing.T) { t.Fatal(err) } } + +func TestErrorNil(t *testing.T) { + c, err := Dial("tcp", "127.0.0.1:65535") + if err == nil { + t.Fatal("Dial 127.0.0.1:65535 succeeded") + } + if c != nil { + t.Fatalf("Dial returned non-nil interface %T(%v) with err != nil", c, c) + } + + // Make Listen fail by relistening on the same address. + l, err := Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatal("Listen 127.0.0.1:0: %v", err) + } + defer l.Close() + l1, err := Listen("tcp", l.Addr().String()) + if err == nil { + t.Fatal("second Listen %v: %v", l.Addr(), err) + } + if l1 != nil { + t.Fatalf("Listen returned non-nil interface %T(%v) with err != nil", l1, l1) + } + + // Make ListenPacket fail by relistening on the same address. + lp, err := ListenPacket("udp", "127.0.0.1:0") + if err != nil { + t.Fatal("Listen 127.0.0.1:0: %v", err) + } + defer lp.Close() + lp1, err := ListenPacket("udp", lp.LocalAddr().String()) + if err == nil { + t.Fatal("second Listen %v: %v", lp.LocalAddr(), err) + } + if lp1 != nil { + t.Fatalf("ListenPacket returned non-nil interface %T(%v) with err != nil", lp1, lp1) + } +} |