Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
3d7c3303
"...en/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "8adc6003ba4dbf5b61bb4f1ce571e9e55e145a99"
Unverified
Commit
3d7c3303
authored
May 26, 2019
by
Chao Ma
Committed by
GitHub
May 26, 2019
Browse files
Add unittest for C++ RPC (#566)
parent
7bdc1619
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
4 deletions
+40
-4
src/graph/network/socket_communicator.h
src/graph/network/socket_communicator.h
+2
-2
tests/cpp/socket_communicator_test.cc
tests/cpp/socket_communicator_test.cc
+37
-0
tests/cpp/tcp_socket_test.cc
tests/cpp/tcp_socket_test.cc
+1
-2
No files found.
src/graph/network/socket_communicator.h
View file @
3d7c3303
...
...
@@ -96,7 +96,7 @@ class SocketSender : public Sender {
/*!
* \brief data buffer
*/
char
*
buffer_
;
char
*
buffer_
=
nullptr
;
};
/*!
...
...
@@ -174,7 +174,7 @@ class SocketReceiver : public Receiver {
/*!
* \brief data buffer
*/
char
*
buffer_
;
char
*
buffer_
=
nullptr
;
/*!
* \brief Process received message in independent threads
...
...
tests/cpp/socket_communicator_test.cc
0 → 100644
View file @
3d7c3303
/*!
* Copyright (c) 2019 by Contributors
* \file msg_queue.cc
* \brief Message queue for DGL distributed training.
*/
#include <gtest/gtest.h>
#include <string.h>
#include <unistd.h>
#include <string>
#include "../src/graph/network/socket_communicator.h"
using
std
::
string
;
using
dgl
::
network
::
SocketSender
;
using
dgl
::
network
::
SocketReceiver
;
TEST
(
SocketCommunicatorTest
,
SendAndRecv
)
{
int
pid
=
fork
();
const
char
*
msg
=
"0123456789"
;
ASSERT_GE
(
pid
,
0
);
if
(
pid
>
0
)
{
// parent: server
char
serbuff
[
10
];
memset
(
serbuff
,
'\0'
,
10
);
SocketReceiver
receiver
;
receiver
.
Wait
(
"127.0.0.1"
,
50051
,
1
,
500
);
receiver
.
Recv
(
serbuff
,
10
);
ASSERT_EQ
(
string
(
"0123456789"
),
string
(
serbuff
,
10
));
receiver
.
Finalize
();
}
else
{
// child: client
sleep
(
1
);
SocketSender
sender
;
sender
.
AddReceiver
(
"127.0.0.1"
,
50051
,
0
);
sender
.
Connect
();
sender
.
Send
(
msg
,
10
,
0
);
sender
.
Finalize
();
}
}
\ No newline at end of file
tests/cpp/tcp_socket_test.cc
View file @
3d7c3303
...
...
@@ -75,7 +75,7 @@ TEST(TCPSocket, SendRecieve) {
sent_bytes
+=
tmp
;
}
}
else
{
// child: client
sleep
(
3
);
// wait for server
sleep
(
1
);
// wait for server
TCPSocket
client
;
ASSERT_TRUE
(
client
.
Connect
(
"127.0.0.1"
,
2049
));
char
clibuff
[
10
];
...
...
@@ -124,5 +124,4 @@ TEST(TCPSocket, SendRecieve) {
ASSERT_EQ
(
bigbuff
[
i
],
'x'
);
}
}
wait
(
0
);
}
\ No newline at end of file
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