mirror of
https://github.com/zeromq/libzmq.git
synced 2025-02-21 22:56:22 +01:00
Merge pull request #1476 from hintjens/master
Problem: lack test case for large stream messages
This commit is contained in:
commit
effc26c695
@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I config
|
|||||||
|
|
||||||
SUBDIRS = doc
|
SUBDIRS = doc
|
||||||
|
|
||||||
DIST_SUBDIRS = builds/msvc doc
|
DIST_SUBDIRS = doc builds builds/msvc
|
||||||
|
|
||||||
pkgconfig_DATA = src/libzmq.pc
|
pkgconfig_DATA = src/libzmq.pc
|
||||||
|
|
||||||
@ -677,7 +677,7 @@ EXTRA_DIST = \
|
|||||||
MAINTAINERS \
|
MAINTAINERS \
|
||||||
src/libzmq.pc.cmake.in \
|
src/libzmq.pc.cmake.in \
|
||||||
src/libzmq.vers \
|
src/libzmq.vers \
|
||||||
tools/curve_keygen.cpp
|
tools/curve_keygen.cpp
|
||||||
|
|
||||||
MAINTAINERCLEANFILES = \
|
MAINTAINERCLEANFILES = \
|
||||||
$(srcdir)/aclocal.m4 \
|
$(srcdir)/aclocal.m4 \
|
||||||
|
34
builds/Makefile.am
Normal file
34
builds/Makefile.am
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Specify all build files that have to go into source packages.
|
||||||
|
# msvc directory does its own stuff.
|
||||||
|
|
||||||
|
EXTRA_DIST = \
|
||||||
|
cygwin/Makefile.cygwin \
|
||||||
|
zos/makelibzmq \
|
||||||
|
zos/cxxall \
|
||||||
|
zos/README.md \
|
||||||
|
zos/makeclean \
|
||||||
|
zos/platform.hpp \
|
||||||
|
zos/zc++ \
|
||||||
|
zos/test_fork.cpp \
|
||||||
|
zos/maketests \
|
||||||
|
zos/runtests \
|
||||||
|
cygwin/Makefile.cygwin \
|
||||||
|
mingw32/Makefile.mingw32 \
|
||||||
|
mingw32/platform.hpp \
|
||||||
|
cmake/Modules \
|
||||||
|
cmake/Modules/FindAsciiDoc.cmake \
|
||||||
|
cmake/Modules/TestZMQVersion.cmake \
|
||||||
|
cmake/Modules/ZMQSourceRunChecks.cmake \
|
||||||
|
cmake/NSIS.template32.in \
|
||||||
|
cmake/platform.hpp.in \
|
||||||
|
cmake/Makefile.am \
|
||||||
|
cmake/Makefile \
|
||||||
|
cmake/NSIS.template64.in \
|
||||||
|
cmake/Makefile.in \
|
||||||
|
valgrind/valgrind.supp \
|
||||||
|
valgrind/vg \
|
||||||
|
nuget/readme.nuget \
|
||||||
|
nuget/libzmq.autopkg \
|
||||||
|
qt-android/android_build_helper.sh \
|
||||||
|
qt-android/ci_build.sh \
|
||||||
|
qt-android/build.sh
|
@ -569,6 +569,7 @@ AC_CONFIG_FILES([ \
|
|||||||
Makefile \
|
Makefile \
|
||||||
src/libzmq.pc \
|
src/libzmq.pc \
|
||||||
doc/Makefile \
|
doc/Makefile \
|
||||||
|
builds/Makefile \
|
||||||
builds/msvc/Makefile \
|
builds/msvc/Makefile \
|
||||||
builds/redhat/zeromq.spec])
|
builds/redhat/zeromq.spec])
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ are given a linger timeout of zero. You must still close all sockets before
|
|||||||
calling zmq_term.
|
calling zmq_term.
|
||||||
|
|
||||||
[horizontal]
|
[horizontal]
|
||||||
Default value:: false (old behavior)
|
Default value:: true (old behavior)
|
||||||
|
|
||||||
|
|
||||||
ZMQ_IO_THREADS: Set number of I/O threads
|
ZMQ_IO_THREADS: Set number of I/O threads
|
||||||
|
@ -45,8 +45,13 @@ typedef struct {
|
|||||||
// This is a greeting matching what 0MQ will send us; note the
|
// This is a greeting matching what 0MQ will send us; note the
|
||||||
// 8-byte size is set to 1 for backwards compatibility
|
// 8-byte size is set to 1 for backwards compatibility
|
||||||
|
|
||||||
static zmtp_greeting_t greeting
|
static zmtp_greeting_t
|
||||||
= { { 0xFF, 0, 0, 0, 0, 0, 0, 0, 1, 0x7F }, { 3, 0 }, { 'N', 'U', 'L', 'L'}, 0, { 0 } };
|
greeting = { { 0xFF, 0, 0, 0, 0, 0, 0, 0, 1, 0x7F },
|
||||||
|
{ 3, 0 },
|
||||||
|
{ 'N', 'U', 'L', 'L'},
|
||||||
|
0,
|
||||||
|
{ 0 }
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_stream_to_dealer (void)
|
test_stream_to_dealer (void)
|
||||||
@ -90,8 +95,8 @@ test_stream_to_dealer (void)
|
|||||||
assert (rc > 0);
|
assert (rc > 0);
|
||||||
assert (zmq_msg_more (&identity));
|
assert (zmq_msg_more (&identity));
|
||||||
|
|
||||||
// Verify the existence of Peer-Address metadata
|
// Verify the existence of Peer-Address metadata
|
||||||
char const* peer_address = zmq_msg_gets (&identity, "Peer-Address");
|
char const *peer_address = zmq_msg_gets (&identity, "Peer-Address");
|
||||||
assert (peer_address != 0);
|
assert (peer_address != 0);
|
||||||
assert (streq (peer_address, "127.0.0.1"));
|
assert (streq (peer_address, "127.0.0.1"));
|
||||||
|
|
||||||
@ -100,7 +105,7 @@ test_stream_to_dealer (void)
|
|||||||
rc = zmq_recv (stream, buffer, 255, 0);
|
rc = zmq_recv (stream, buffer, 255, 0);
|
||||||
assert (rc == 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");
|
peer_address = zmq_msg_gets (&identity, "Peer-Address");
|
||||||
assert (peer_address != 0);
|
assert (peer_address != 0);
|
||||||
assert (streq (peer_address, "127.0.0.1"));
|
assert (streq (peer_address, "127.0.0.1"));
|
||||||
@ -111,7 +116,7 @@ test_stream_to_dealer (void)
|
|||||||
assert (rc > 0);
|
assert (rc > 0);
|
||||||
assert (zmq_msg_more (&identity));
|
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");
|
peer_address = zmq_msg_gets (&identity, "Peer-Address");
|
||||||
assert (peer_address != 0);
|
assert (peer_address != 0);
|
||||||
assert (streq (peer_address, "127.0.0.1"));
|
assert (streq (peer_address, "127.0.0.1"));
|
||||||
@ -189,6 +194,29 @@ test_stream_to_dealer (void)
|
|||||||
assert (rc == 5);
|
assert (rc == 5);
|
||||||
assert (memcmp (buffer, "World", 5) == 0);
|
assert (memcmp (buffer, "World", 5) == 0);
|
||||||
|
|
||||||
|
// Test large messages over STREAM socket
|
||||||
|
# define 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);
|
rc = zmq_close (dealer);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
|
|
||||||
@ -297,7 +325,6 @@ test_stream_to_stream (void)
|
|||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
setup_test_environment();
|
setup_test_environment();
|
||||||
|
@ -90,7 +90,7 @@ bounce (void *server, void *client)
|
|||||||
rc = zmq_getsockopt (server, ZMQ_RCVMORE, &rcvmore, &sz);
|
rc = zmq_getsockopt (server, ZMQ_RCVMORE, &rcvmore, &sz);
|
||||||
assert (rc == 0);
|
assert (rc == 0);
|
||||||
assert (!rcvmore);
|
assert (!rcvmore);
|
||||||
|
|
||||||
// Send two parts back to client
|
// Send two parts back to client
|
||||||
rc = zmq_send (server, buffer, 32, ZMQ_SNDMORE);
|
rc = zmq_send (server, buffer, 32, ZMQ_SNDMORE);
|
||||||
assert (rc == 32);
|
assert (rc == 32);
|
||||||
@ -233,7 +233,7 @@ void s_recv_seq (void *socket, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
va_start (ap, socket);
|
va_start (ap, socket);
|
||||||
const char * data = va_arg (ap, const char *);
|
const char * data = va_arg (ap, const char *);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int rc = zmq_msg_recv (&msg, socket, 0);
|
int rc = zmq_msg_recv (&msg, socket, 0);
|
||||||
assert (rc != -1);
|
assert (rc != -1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user