Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
735cf529
Commit
735cf529
authored
Jul 11, 2013
by
ChaiShushan
Committed by
Russ Cox
Jul 11, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net/rpc: fix a test bug
R=golang-dev, rsc CC=golang-dev
https://golang.org/cl/10855043
parent
01e1b0cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
server_test.go
src/pkg/net/rpc/server_test.go
+22
-1
No files found.
src/pkg/net/rpc/server_test.go
View file @
735cf529
...
@@ -99,11 +99,12 @@ func startNewServer() {
...
@@ -99,11 +99,12 @@ func startNewServer() {
newServer
=
NewServer
()
newServer
=
NewServer
()
newServer
.
Register
(
new
(
Arith
))
newServer
.
Register
(
new
(
Arith
))
newServer
.
RegisterName
(
"net.rpc.Arith"
,
new
(
Arith
))
newServer
.
RegisterName
(
"net.rpc.Arith"
,
new
(
Arith
))
newServer
.
RegisterName
(
"newServer.Arith"
,
new
(
Arith
))
var
l
net
.
Listener
var
l
net
.
Listener
l
,
newServerAddr
=
listenTCP
()
l
,
newServerAddr
=
listenTCP
()
log
.
Println
(
"NewServer test RPC server listening on"
,
newServerAddr
)
log
.
Println
(
"NewServer test RPC server listening on"
,
newServerAddr
)
go
Accept
(
l
)
go
newServer
.
Accept
(
l
)
newServer
.
HandleHTTP
(
newHttpPath
,
"/bar"
)
newServer
.
HandleHTTP
(
newHttpPath
,
"/bar"
)
httpOnce
.
Do
(
startHttpServer
)
httpOnce
.
Do
(
startHttpServer
)
...
@@ -120,6 +121,7 @@ func TestRPC(t *testing.T) {
...
@@ -120,6 +121,7 @@ func TestRPC(t *testing.T) {
testRPC
(
t
,
serverAddr
)
testRPC
(
t
,
serverAddr
)
newOnce
.
Do
(
startNewServer
)
newOnce
.
Do
(
startNewServer
)
testRPC
(
t
,
newServerAddr
)
testRPC
(
t
,
newServerAddr
)
testNewServerRPC
(
t
,
newServerAddr
)
}
}
func
testRPC
(
t
*
testing
.
T
,
addr
string
)
{
func
testRPC
(
t
*
testing
.
T
,
addr
string
)
{
...
@@ -249,6 +251,25 @@ func testRPC(t *testing.T, addr string) {
...
@@ -249,6 +251,25 @@ func testRPC(t *testing.T, addr string) {
}
}
}
}
func
testNewServerRPC
(
t
*
testing
.
T
,
addr
string
)
{
client
,
err
:=
Dial
(
"tcp"
,
addr
)
if
err
!=
nil
{
t
.
Fatal
(
"dialing"
,
err
)
}
defer
client
.
Close
()
// Synchronous calls
args
:=
&
Args
{
7
,
8
}
reply
:=
new
(
Reply
)
err
=
client
.
Call
(
"newServer.Arith.Add"
,
args
,
reply
)
if
err
!=
nil
{
t
.
Errorf
(
"Add: expected no error but got string %q"
,
err
.
Error
())
}
if
reply
.
C
!=
args
.
A
+
args
.
B
{
t
.
Errorf
(
"Add: expected %d got %d"
,
reply
.
C
,
args
.
A
+
args
.
B
)
}
}
func
TestHTTP
(
t
*
testing
.
T
)
{
func
TestHTTP
(
t
*
testing
.
T
)
{
once
.
Do
(
startServer
)
once
.
Do
(
startServer
)
testHTTPRPC
(
t
,
""
)
testHTTPRPC
(
t
,
""
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment