Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
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
libzmq
Commits
92c4decb
Commit
92c4decb
authored
Jul 19, 2015
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: lack test case for large stream messages
Solution: added to test_stream.cpp
parent
b7910314
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
10 deletions
+37
-10
test_stream.cpp
tests/test_stream.cpp
+34
-7
testutil.hpp
tests/testutil.hpp
+3
-3
No files found.
tests/test_stream.cpp
View file @
92c4decb
...
...
@@ -45,8 +45,13 @@ typedef struct {
// This is a greeting matching what 0MQ will send us; note the
// 8-byte size is set to 1 for backwards compatibility
static
zmtp_greeting_t
greeting
=
{
{
0xFF
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
0x7F
},
{
3
,
0
},
{
'N'
,
'U'
,
'L'
,
'L'
},
0
,
{
0
}
};
static
zmtp_greeting_t
greeting
=
{
{
0xFF
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
0x7F
},
{
3
,
0
},
{
'N'
,
'U'
,
'L'
,
'L'
},
0
,
{
0
}
};
static
void
test_stream_to_dealer
(
void
)
...
...
@@ -90,8 +95,8 @@ test_stream_to_dealer (void)
assert
(
rc
>
0
);
assert
(
zmq_msg_more
(
&
identity
));
// Verify the existence of Peer-Address metadata
char
const
*
peer_address
=
zmq_msg_gets
(
&
identity
,
"Peer-Address"
);
//
Verify the existence of Peer-Address metadata
char
const
*
peer_address
=
zmq_msg_gets
(
&
identity
,
"Peer-Address"
);
assert
(
peer_address
!=
0
);
assert
(
streq
(
peer_address
,
"127.0.0.1"
));
...
...
@@ -100,7 +105,7 @@ test_stream_to_dealer (void)
rc
=
zmq_recv
(
stream
,
buffer
,
255
,
0
);
assert
(
rc
==
0
);
// Verify the existence of Peer-Address metadata
//
Verify the existence of Peer-Address metadata
peer_address
=
zmq_msg_gets
(
&
identity
,
"Peer-Address"
);
assert
(
peer_address
!=
0
);
assert
(
streq
(
peer_address
,
"127.0.0.1"
));
...
...
@@ -111,7 +116,7 @@ test_stream_to_dealer (void)
assert
(
rc
>
0
);
assert
(
zmq_msg_more
(
&
identity
));
// Verify the existence of Peer-Address metadata
//
Verify the existence of Peer-Address metadata
peer_address
=
zmq_msg_gets
(
&
identity
,
"Peer-Address"
);
assert
(
peer_address
!=
0
);
assert
(
streq
(
peer_address
,
"127.0.0.1"
));
...
...
@@ -189,6 +194,29 @@ test_stream_to_dealer (void)
assert
(
rc
==
5
);
assert
(
memcmp
(
buffer
,
"World"
,
5
)
==
0
);
// Test large messages over STREAM socket
int
size
=
64000
;
uint8_t
msgout
[
size
];
memset
(
msgout
,
0xAB
,
size
);
zmq_send
(
dealer
,
msgout
,
size
,
0
);
uint8_t
msgin
[
9
+
size
];
memset
(
msgin
,
0
,
9
+
size
);
bytes_read
=
0
;
while
(
bytes_read
<
9
+
size
)
{
// Get identity frame
rc
=
zmq_recv
(
stream
,
buffer
,
256
,
0
);
assert
(
rc
>
0
);
// Get next chunk
rc
=
zmq_recv
(
stream
,
msgin
+
bytes_read
,
9
+
size
-
bytes_read
,
0
);
assert
(
rc
>
0
);
bytes_read
+=
rc
;
}
int
byte_nbr
;
for
(
byte_nbr
=
0
;
byte_nbr
<
size
;
byte_nbr
++
)
{
if
(
msgin
[
9
+
byte_nbr
]
!=
0xAB
)
assert
(
false
);
}
rc
=
zmq_close
(
dealer
);
assert
(
rc
==
0
);
...
...
@@ -297,7 +325,6 @@ test_stream_to_stream (void)
assert
(
rc
==
0
);
}
int
main
(
void
)
{
setup_test_environment
();
...
...
tests/testutil.hpp
View file @
92c4decb
...
...
@@ -32,7 +32,7 @@
#include "../include/zmq.h"
#include "../src/stdint.hpp"
#include "platform.hpp"
#include "
../src/
platform.hpp"
// This defines the settle time used in tests; raise this if we
// get test failures on slower systems due to binds/connects not
...
...
@@ -90,7 +90,7 @@ bounce (void *server, void *client)
rc
=
zmq_getsockopt
(
server
,
ZMQ_RCVMORE
,
&
rcvmore
,
&
sz
);
assert
(
rc
==
0
);
assert
(
!
rcvmore
);
// Send two parts back to client
rc
=
zmq_send
(
server
,
buffer
,
32
,
ZMQ_SNDMORE
);
assert
(
rc
==
32
);
...
...
@@ -233,7 +233,7 @@ void s_recv_seq (void *socket, ...)
va_list
ap
;
va_start
(
ap
,
socket
);
const
char
*
data
=
va_arg
(
ap
,
const
char
*
);
while
(
true
)
{
int
rc
=
zmq_msg_recv
(
&
msg
,
socket
,
0
);
assert
(
rc
!=
-
1
);
...
...
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