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
85f2d1d9
Unverified
Commit
85f2d1d9
authored
May 26, 2019
by
Chao Ma
Committed by
GitHub
May 26, 2019
Browse files
[CI] Fix CI for cpp test (#570)
* fix CI for cpp test * update port number
parent
3d7c3303
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
135 deletions
+8
-135
tests/cpp/socket_communicator_test.cc
tests/cpp/socket_communicator_test.cc
+8
-8
tests/cpp/tcp_socket_test.cc
tests/cpp/tcp_socket_test.cc
+0
-127
No files found.
tests/cpp/socket_communicator_test.cc
View file @
85f2d1d9
...
...
@@ -22,14 +22,14 @@ TEST(SocketCommunicatorTest, SendAndRecv) {
char
serbuff
[
10
];
memset
(
serbuff
,
'\0'
,
10
);
SocketReceiver
receiver
;
receiver
.
Wait
(
"127.0.0.1"
,
50051
,
1
,
500
);
receiver
.
Wait
(
"127.0.0.1"
,
2049
,
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
.
AddReceiver
(
"127.0.0.1"
,
2049
,
0
);
sender
.
Connect
();
sender
.
Send
(
msg
,
10
,
0
);
sender
.
Finalize
();
...
...
tests/cpp/tcp_socket_test.cc
deleted
100644 → 0
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/tcp_socket.h"
using
std
::
string
;
using
dgl
::
network
::
TCPSocket
;
const
size_t
kDataLength
=
9999999
;
// 9.5 MB
TEST
(
TCPSocket
,
SendRecieve
)
{
int
pid
=
fork
();
const
char
*
msg
=
"0123456789"
;
ASSERT_GE
(
pid
,
0
);
if
(
pid
>
0
)
{
// parent: server
TCPSocket
server
;
TCPSocket
client
;
string
cl_ip
;
int
cl_port
;
char
serbuff
[
10
];
memset
(
serbuff
,
'\0'
,
10
);
server
.
SetTimeout
(
5
*
60
*
1000
);
ASSERT_TRUE
(
server
.
Bind
(
"127.0.0.1"
,
2049
));
ASSERT_TRUE
(
server
.
Listen
(
3
));
ASSERT_TRUE
(
server
.
Accept
(
&
client
,
&
cl_ip
,
&
cl_port
));
// Small block
for
(
int
i
=
0
;
i
<
9999
;
++
i
)
{
int
tmp
;
int
recieved_bytes
=
0
;
while
(
recieved_bytes
<
10
)
{
int
max_len
=
10
-
recieved_bytes
;
tmp
=
client
.
Receive
(
&
serbuff
[
recieved_bytes
],
max_len
);
ASSERT_GE
(
tmp
,
0
);
recieved_bytes
+=
tmp
;
}
ASSERT_EQ
(
string
(
"0123456789"
),
string
(
serbuff
,
10
));
int
sent_bytes
=
0
;
while
(
sent_bytes
<
10
)
{
int
max_len
=
10
-
sent_bytes
;
tmp
=
client
.
Send
(
&
msg
[
sent_bytes
],
max_len
);
ASSERT_GE
(
tmp
,
0
);
sent_bytes
+=
tmp
;
}
}
// Big block
char
*
bigdata
=
new
char
[
kDataLength
];
char
*
bigbuff
=
new
char
[
kDataLength
];
memset
(
bigdata
,
'x'
,
kDataLength
);
memset
(
bigbuff
,
'\0'
,
kDataLength
);
int
recieved_bytes
=
0
;
while
(
recieved_bytes
<
kDataLength
)
{
int
max_len
=
kDataLength
-
recieved_bytes
;
int
tmp
=
client
.
Receive
(
&
bigbuff
[
recieved_bytes
],
max_len
);
ASSERT_GE
(
tmp
,
0
);
recieved_bytes
+=
tmp
;
}
for
(
size_t
i
=
0
;
i
<
kDataLength
;
++
i
)
{
ASSERT_EQ
(
bigbuff
[
i
],
'x'
);
}
int
sent_bytes
=
0
;
while
(
sent_bytes
<
kDataLength
)
{
int
max_len
=
kDataLength
-
sent_bytes
;
int
tmp
=
client
.
Send
(
&
bigdata
[
sent_bytes
],
max_len
);
ASSERT_GE
(
tmp
,
0
);
sent_bytes
+=
tmp
;
}
}
else
{
// child: client
sleep
(
1
);
// wait for server
TCPSocket
client
;
ASSERT_TRUE
(
client
.
Connect
(
"127.0.0.1"
,
2049
));
char
clibuff
[
10
];
memset
(
clibuff
,
'\0'
,
10
);
// Small block
for
(
int
i
=
0
;
i
<
9999
;
++
i
)
{
int
tmp
;
int
sent_bytes
=
0
;
while
(
sent_bytes
<
10
)
{
int
max_len
=
10
-
sent_bytes
;
tmp
=
client
.
Send
(
&
msg
[
sent_bytes
],
max_len
);
ASSERT_GE
(
tmp
,
0
);
sent_bytes
+=
tmp
;
}
int
recieved_bytes
=
0
;
while
(
recieved_bytes
<
10
)
{
int
max_len
=
10
-
recieved_bytes
;
tmp
=
client
.
Receive
(
&
clibuff
[
recieved_bytes
],
max_len
);
ASSERT_GE
(
tmp
,
0
);
recieved_bytes
+=
tmp
;
}
ASSERT_EQ
(
string
(
"0123456789"
),
string
(
clibuff
,
10
));
}
// Big block
char
*
bigdata
=
new
char
[
kDataLength
];
char
*
bigbuff
=
new
char
[
kDataLength
];
memset
(
bigdata
,
'x'
,
kDataLength
);
memset
(
bigbuff
,
'\0'
,
kDataLength
);
int
sent_bytes
=
0
;
while
(
sent_bytes
<
kDataLength
)
{
int
max_len
=
kDataLength
-
sent_bytes
;
int
tmp
=
client
.
Send
(
&
bigdata
[
sent_bytes
],
max_len
);
ASSERT_GE
(
tmp
,
0
);
sent_bytes
+=
tmp
;
}
int
recieved_bytes
=
0
;
while
(
recieved_bytes
<
kDataLength
)
{
int
max_len
=
kDataLength
-
recieved_bytes
;
int
tmp
=
client
.
Receive
(
&
bigbuff
[
recieved_bytes
],
max_len
);
ASSERT_GE
(
tmp
,
0
);
recieved_bytes
+=
tmp
;
}
for
(
size_t
i
=
0
;
i
<
kDataLength
;
++
i
)
{
ASSERT_EQ
(
bigbuff
[
i
],
'x'
);
}
}
}
\ 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