Commit 92c4decb authored by Pieter Hintjens's avatar Pieter Hintjens

Problem: lack test case for large stream messages

Solution: added to test_stream.cpp
parent b7910314
...@@ -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
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); 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();
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "../include/zmq.h" #include "../include/zmq.h"
#include "../src/stdint.hpp" #include "../src/stdint.hpp"
#include "platform.hpp" #include "../src/platform.hpp"
// This defines the settle time used in tests; raise this if we // This defines the settle time used in tests; raise this if we
// get test failures on slower systems due to binds/connects not // get test failures on slower systems due to binds/connects not
......
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