Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
28073325
Commit
28073325
authored
Nov 09, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some commentary to the test.
parent
fd8405d9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
13 deletions
+27
-13
rpc-twoparty-test.c++
c++/src/capnp/rpc-twoparty-test.c++
+22
-8
mega-test-quick.cfg
mega-test-quick.cfg
+5
-5
No files found.
c++/src/capnp/rpc-twoparty-test.c++
View file @
28073325
...
@@ -53,41 +53,55 @@ private:
...
@@ -53,41 +53,55 @@ private:
};
};
void
runServer
(
kj
::
Promise
<
void
>
quit
,
kj
::
Own
<
kj
::
AsyncIoStream
>
stream
,
int
&
callCount
)
{
void
runServer
(
kj
::
Promise
<
void
>
quit
,
kj
::
Own
<
kj
::
AsyncIoStream
>
stream
,
int
&
callCount
)
{
// Set up the server.
kj
::
UnixEventLoop
eventLoop
;
kj
::
UnixEventLoop
eventLoop
;
TwoPartyVatNetwork
network
(
eventLoop
,
*
stream
,
rpc
::
twoparty
::
Side
::
SERVER
);
TwoPartyVatNetwork
network
(
eventLoop
,
*
stream
,
rpc
::
twoparty
::
Side
::
SERVER
);
TestRestorer
restorer
(
callCount
);
TestRestorer
restorer
(
callCount
);
auto
server
=
makeRpcServer
(
network
,
restorer
,
eventLoop
);
auto
server
=
makeRpcServer
(
network
,
restorer
,
eventLoop
);
// Wait until quit promise is fulfilled.
eventLoop
.
wait
(
kj
::
mv
(
quit
));
eventLoop
.
wait
(
kj
::
mv
(
quit
));
}
}
Capability
::
Client
connect
(
RpcSystem
<
rpc
::
twoparty
::
SturdyRefHostId
>&
client
,
Capability
::
Client
getPersistentCap
(
RpcSystem
<
rpc
::
twoparty
::
SturdyRefHostId
>&
client
,
rpc
::
twoparty
::
Side
side
,
rpc
::
twoparty
::
Side
side
,
test
::
TestSturdyRefObjectId
::
Tag
tag
)
{
test
::
TestSturdyRefObjectId
::
Tag
tag
)
{
// Create the SturdyRefHostId.
MallocMessageBuilder
hostIdMessage
(
8
);
MallocMessageBuilder
hostIdMessage
(
8
);
MallocMessageBuilder
objectIdMessage
(
8
);
auto
hostId
=
hostIdMessage
.
initRoot
<
rpc
::
twoparty
::
SturdyRefHostId
>
();
auto
hostId
=
hostIdMessage
.
initRoot
<
rpc
::
twoparty
::
SturdyRefHostId
>
();
hostId
.
setSide
(
side
);
hostId
.
setSide
(
side
);
// Create the SturdyRefObjectId.
MallocMessageBuilder
objectIdMessage
(
8
);
objectIdMessage
.
initRoot
<
test
::
TestSturdyRefObjectId
>
().
setTag
(
tag
);
objectIdMessage
.
initRoot
<
test
::
TestSturdyRefObjectId
>
().
setTag
(
tag
);
// Connect to the remote capability.
return
client
.
connect
(
hostId
,
objectIdMessage
.
getRoot
<
ObjectPointer
>
());
return
client
.
connect
(
hostId
,
objectIdMessage
.
getRoot
<
ObjectPointer
>
());
}
}
TEST
(
TwoPartyNetwork
,
Basic
)
{
TEST
(
TwoPartyNetwork
,
Basic
)
{
auto
quitter
=
kj
::
newPromiseAndFulfiller
<
void
>
();
auto
pipe
=
kj
::
newTwoWayPipe
();
int
callCount
=
0
;
int
callCount
=
0
;
// We'll communicate over this two-way pipe (actually, a socketpair).
auto
pipe
=
kj
::
newTwoWayPipe
();
// Start up server in another thread.
auto
quitter
=
kj
::
newPromiseAndFulfiller
<
void
>
();
kj
::
Thread
thread
([
&
]()
{
kj
::
Thread
thread
([
&
]()
{
runServer
(
kj
::
mv
(
quitter
.
promise
),
kj
::
mv
(
pipe
.
ends
[
1
]),
callCount
);
runServer
(
kj
::
mv
(
quitter
.
promise
),
kj
::
mv
(
pipe
.
ends
[
1
]),
callCount
);
});
});
KJ_DEFER
(
quitter
.
fulfiller
->
fulfill
());
KJ_DEFER
(
quitter
.
fulfiller
->
fulfill
());
// Stop the server loop before destroying the thread.
// Set up the client-side objects.
kj
::
UnixEventLoop
loop
;
kj
::
UnixEventLoop
loop
;
TwoPartyVatNetwork
network
(
loop
,
*
pipe
.
ends
[
0
],
rpc
::
twoparty
::
Side
::
CLIENT
);
TwoPartyVatNetwork
network
(
loop
,
*
pipe
.
ends
[
0
],
rpc
::
twoparty
::
Side
::
CLIENT
);
auto
rpcClient
=
makeRpcClient
(
network
,
loop
);
auto
rpcClient
=
makeRpcClient
(
network
,
loop
);
auto
client
=
connect
(
rpcClient
,
rpc
::
twoparty
::
Side
::
SERVER
,
// Request the particular capability from the server.
auto
client
=
getPersistentCap
(
rpcClient
,
rpc
::
twoparty
::
Side
::
SERVER
,
test
::
TestSturdyRefObjectId
::
Tag
::
TEST_INTERFACE
).
castAs
<
test
::
TestInterface
>
();
test
::
TestSturdyRefObjectId
::
Tag
::
TEST_INTERFACE
).
castAs
<
test
::
TestInterface
>
();
// Use the capability.
auto
request1
=
client
.
fooRequest
();
auto
request1
=
client
.
fooRequest
();
request1
.
setI
(
123
);
request1
.
setI
(
123
);
request1
.
setJ
(
true
);
request1
.
setJ
(
true
);
...
...
mega-test-quick.cfg
View file @
28073325
linux-gcc-4.7 1
632
./super-test.sh tmpdir capnp-gcc-4.7 quick
linux-gcc-4.7 1
704
./super-test.sh tmpdir capnp-gcc-4.7 quick
linux-gcc-4.8 1
635
./super-test.sh tmpdir capnp-gcc-4.8 quick gcc-4.8
linux-gcc-4.8 1
707
./super-test.sh tmpdir capnp-gcc-4.8 quick gcc-4.8
linux-clang 1
652
./super-test.sh tmpdir capnp-clang quick clang
linux-clang 1
724
./super-test.sh tmpdir capnp-clang quick clang
mac 7
65
./super-test.sh remote beat caffeinate quick
mac 7
91
./super-test.sh remote beat caffeinate quick
cygwin 7
69
./super-test.sh remote Kenton@flashman quick
cygwin 7
95
./super-test.sh remote Kenton@flashman quick
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