Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
98441d38
Commit
98441d38
authored
Dec 11, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3ca87f70
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
10 deletions
+61
-10
t/neo/connection_test.go
t/neo/connection_test.go
+61
-10
No files found.
t/neo/connection_test.go
View file @
98441d38
...
@@ -19,40 +19,91 @@ import (
...
@@ -19,40 +19,91 @@ import (
"testing"
"testing"
)
)
func
xsend
(
c
*
Conn
,
pkt
PktBuf
)
{
func
xsend
(
c
*
Conn
,
pkt
*
PktBuf
)
{
err
:=
c
.
Send
(
pkt
)
err
:=
c
.
Send
(
pkt
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
// XXX make sure this happens in main goroutine
}
}
}
}
func
xrecv
(
c
*
Conn
)
PktBuf
{
func
xrecv
(
c
*
Conn
)
*
PktBuf
{
pkt
,
err
:=
c
.
Recv
()
pkt
,
err
:=
c
.
Recv
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
// XXX make sure this happens in main goroutine
}
}
return
pkt
return
pkt
}
}
func
xsendPkt
(
nl
*
NodeLink
,
pkt
*
PktBuf
)
{
err
:=
nl
.
sendPkt
(
pkt
)
if
err
!=
nil
{
panic
(
"TODO"
)
}
return
err
}
func
xrecvPkt
(
nl
*
NodeLink
)
*
PktBuf
{
pkt
,
err
:=
nl
.
recvPkt
()
if
err
!=
nil
{
panic
(
"TODO"
)
}
return
pkt
}
func
xspawn
(
funcv
...
func
())
{
for
f
:=
range
funcv
{
go
func
()
{
defer
func
()
{
e
:=
recover
()
if
e
==
nil
{
return
}
}
}
}
}
func
TestNodeLink
(
t
*
testing
.
T
)
{
func
TestNodeLink
(
t
*
testing
.
T
)
{
// TODO verify NodeLink via net.Pipe
// TODO verify NodeLink via net.Pipe
node1
,
node2
:=
net
.
Pipe
()
node1
,
node2
:=
net
.
Pipe
()
nl1
:=
NewNodeLink
(
node1
)
nl1
:=
NewNodeLink
(
node1
)
nl2
:=
NewNodeLink
(
node2
)
nl2
:=
NewNodeLink
(
node2
)
// TODO setup context
// TODO on context.cancel -> nl{1,2} -> Close
// TODO every func: run with exception catcher (including t.Fatal)
// if caught:
// * ctx.cancel
// * wait all for finish
// * rethrough in main
// first check raw exchange works
// first check raw exchange works
go
func
()
{
go
func
()
{
err
:=
nl1
.
sendPkt
(
...
)
pkt
=
...
err
:=
nl1
.
sendPkt
(
pkt
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
...
)
// XXX bad in goroutine
t
.
Fatal
(
...
)
// XXX bad in goroutine
}
}
pkt
,
err
=
nl1
.
recvPkt
()
if
err
!=
nil
{
t
.
Fatal
(
...
)
}
// TODO check pkt == what was sent back
}()
}()
pkt
,
err
:=
nl2
.
recvPkt
(
...
)
go
func
()
{
if
err
!=
nil
{
pkt
,
err
:=
nl2
.
recvPkt
()
t
.
Fatal
(
...
)
if
err
!=
nil
{
t
.
Fatal
(
...
)
}
// TODO check pkt == what was sent
// TODO change pkt a bit
// send pkt back
err
=
nl2
.
sendPkt
(
pkt
)
if
err
!=
nil
{
t
.
Fatal
(
...
)
// XXX bad in goroutine
}
}
}
// TODO check pkt == what was sent
// TODO also check ^^^ in opposite direction
/*
/*
// test 1 channels on top of nodelink
// test 1 channels on top of nodelink
...
...
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