Commit effc26c6 authored by Constantin Rack's avatar Constantin Rack

Merge pull request #1476 from hintjens/master

Problem: lack test case for large stream messages
parents 08c2a927 fd9bd1b2
...@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I config ...@@ -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
......
# 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([ \ ...@@ -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 ...@@ -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 { ...@@ -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)
...@@ -91,7 +96,7 @@ test_stream_to_dealer (void) ...@@ -91,7 +96,7 @@ test_stream_to_dealer (void)
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"));
...@@ -189,6 +194,29 @@ test_stream_to_dealer (void) ...@@ -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) ...@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment