]> Cypherpunks repositories - gostls13.git/commitdiff
net: use newLocalListener in TestClosingListener.
authorIan Lance Taylor <iant@golang.org>
Wed, 27 Sep 2017 00:47:51 +0000 (17:47 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 28 Sep 2017 03:02:07 +0000 (03:02 +0000)
Updates #21856

Change-Id: I9baa51fe23e6dd2fcf9dd14f7acfaf7457571e1d
Reviewed-on: https://go-review.googlesource.com/66334
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
src/net/listen_test.go

index 63fb144fdc16be6342c39eb39e82aeaea9b697d5..c15b6bdc8f955623bbbaccead09dc83e6163cb4d 100644 (file)
@@ -700,15 +700,15 @@ func multicastRIBContains(ip IP) (bool, error) {
 
 // Issue 21856.
 func TestClosingListener(t *testing.T) {
-       listener, err := Listen("tcp", ":0")
+       ln, err := newLocalListener("tcp")
        if err != nil {
                t.Fatal(err)
        }
-       addr := listener.Addr()
+       addr := ln.Addr()
 
        go func() {
                for {
-                       c, err := listener.Accept()
+                       c, err := ln.Accept()
                        if err != nil {
                                return
                        }
@@ -721,10 +721,11 @@ func TestClosingListener(t *testing.T) {
        // testing anything, which is OK.
        time.Sleep(time.Millisecond)
 
-       listener.Close()
+       ln.Close()
 
-       _, err = Listen("tcp", addr.String())
+       ln, err = Listen("tcp", addr.String())
        if err != nil {
-               t.Error(err)
+               t.Fatal(err)
        }
+       ln.Close()
 }