Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
1 deletion
+22
-1
src/pkg/net/rpc/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() {
newServer
=
NewServer
()
newServer
.
Register
(
new
(
Arith
))
newServer
.
RegisterName
(
"net.rpc.Arith"
,
new
(
Arith
))
newServer
.
RegisterName
(
"newServer.Arith"
,
new
(
Arith
))
var
l
net
.
Listener
l
,
newServerAddr
=
listenTCP
()
log
.
Println
(
"NewServer test RPC server listening on"
,
newServerAddr
)
go
Accept
(
l
)
go
newServer
.
Accept
(
l
)
newServer
.
HandleHTTP
(
newHttpPath
,
"/bar"
)
httpOnce
.
Do
(
startHttpServer
)
...
...
@@ -120,6 +121,7 @@ func TestRPC(t *testing.T) {
testRPC
(
t
,
serverAddr
)
newOnce
.
Do
(
startNewServer
)
testRPC
(
t
,
newServerAddr
)
testNewServerRPC
(
t
,
newServerAddr
)
}
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
)
{
once
.
Do
(
startServer
)
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