Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(593)

Side by Side Diff: src/pkg/net/tcp_test.go

Issue 6525048: code review 6525048: net: protocol specific listen functions return a proper... (Closed)
Patch Set: diff -r 0b46d6fe2f1c https://go.googlecode.com/hg/ Created 11 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/net/iprawsock_posix.go ('k') | src/pkg/net/tcpsock_plan9.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Go Authors. All rights reserved. 1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package net 5 package net
6 6
7 import ( 7 import (
8 "runtime" 8 "runtime"
9 "testing" 9 "testing"
10 "time" 10 "time"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if !sendMsg(c, buf[:]) || !recvMsg(c, buf[:]) { 109 if !sendMsg(c, buf[:]) || !recvMsg(c, buf[:]) {
110 break 110 break
111 } 111 }
112 } 112 }
113 }() 113 }()
114 } 114 }
115 for i := 0; i < cap(sem); i++ { 115 for i := 0; i < cap(sem); i++ {
116 sem <- true 116 sem <- true
117 } 117 }
118 } 118 }
119
120 var tcpListenerNameTests = []struct {
121 net string
122 laddr *TCPAddr
123 }{
124 {"tcp4", &TCPAddr{IP: IPv4(127, 0, 0, 1)}},
125 {"tcp4", &TCPAddr{}},
126 {"tcp4", nil},
127 }
128
129 func TestTCPListenerName(t *testing.T) {
130 if testing.Short() || !*testExternal {
131 t.Logf("skipping test to avoid external network")
132 return
133 }
134
135 for _, tt := range tcpListenerNameTests {
136 ln, err := ListenTCP(tt.net, tt.laddr)
137 if err != nil {
138 t.Errorf("ListenTCP failed: %v", err)
139 return
140 }
141 defer ln.Close()
142 la := ln.Addr()
143 if a, ok := la.(*TCPAddr); !ok || a.Port == 0 {
144 t.Errorf("got %v; expected a proper address with non-zer o port number", la)
145 return
146 }
147 }
148 }
OLDNEW
« no previous file with comments | « src/pkg/net/iprawsock_posix.go ('k') | src/pkg/net/tcpsock_plan9.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b