2013-06-27 20:47:34 +02:00
|
|
|
/*
|
2017-05-01 12:11:11 +01:00
|
|
|
Copyright (c) 2007-2017 Contributors as noted in the AUTHORS file
|
2013-06-27 20:47:34 +02:00
|
|
|
|
2015-06-02 22:33:55 +02:00
|
|
|
This file is part of libzmq, the ZeroMQ core engine in C++.
|
2013-06-27 20:47:34 +02:00
|
|
|
|
2015-06-02 22:33:55 +02:00
|
|
|
libzmq is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License (LGPL) as published
|
|
|
|
by the Free Software Foundation; either version 3 of the License, or
|
2013-06-27 20:47:34 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
2015-06-02 22:33:55 +02:00
|
|
|
As a special exception, the Contributors give you permission to link
|
|
|
|
this library with independent modules to produce an executable,
|
|
|
|
regardless of the license terms of these independent modules, and to
|
|
|
|
copy and distribute the resulting executable under terms of your choice,
|
|
|
|
provided that you also meet, for each linked independent module, the
|
|
|
|
terms and conditions of the license of that module. An independent
|
|
|
|
module is a module which is not derived from or based on this library.
|
|
|
|
If you modify this library, you must extend this exception to your
|
|
|
|
version of the library.
|
|
|
|
|
|
|
|
libzmq is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2013-08-17 13:43:45 +01:00
|
|
|
#include "testutil.hpp"
|
2018-08-20 17:44:16 +02:00
|
|
|
#include "testutil_unity.hpp"
|
|
|
|
|
2019-03-23 08:04:57 -04:00
|
|
|
#include <string.h>
|
|
|
|
|
2019-03-24 12:51:28 -04:00
|
|
|
SETUP_TEARDOWN_TESTCONTEXT
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// ZMTP protocol greeting structure
|
|
|
|
|
2018-08-20 17:44:16 +02:00
|
|
|
typedef uint8_t byte;
|
2018-02-01 11:46:09 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
byte signature[10]; // 0xFF 8*0x00 0x7F
|
|
|
|
byte version[2]; // 0x03 0x00 for ZMTP/3.0
|
|
|
|
byte mechanism[20]; // "NULL"
|
2013-06-27 20:47:34 +02:00
|
|
|
byte as_server;
|
2018-02-01 11:46:09 +01:00
|
|
|
byte filler[31];
|
2013-06-27 20:47:34 +02:00
|
|
|
} zmtp_greeting_t;
|
|
|
|
|
2018-02-01 11:46:09 +01:00
|
|
|
#define ZMTP_DEALER 5 // Socket type constants
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// This is a greeting matching what 0MQ will send us; note the
|
|
|
|
// 8-byte size is set to 1 for backwards compatibility
|
|
|
|
|
2018-02-01 11:46:09 +01:00
|
|
|
static zmtp_greeting_t greeting = {
|
|
|
|
{0xFF, 0, 0, 0, 0, 0, 0, 0, 1, 0x7F}, {3, 0}, {'N', 'U', 'L', 'L'}, 0, {0}};
|
2013-06-27 20:47:34 +02:00
|
|
|
|
2018-08-20 17:44:16 +02:00
|
|
|
static void test_stream_to_dealer ()
|
2013-06-27 20:47:34 +02:00
|
|
|
{
|
|
|
|
int rc;
|
2017-05-01 12:11:11 +01:00
|
|
|
char my_endpoint[MAX_SOCKET_STRING];
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// We'll be using this socket in raw mode
|
2018-08-20 17:44:16 +02:00
|
|
|
void *stream = test_context_socket (ZMQ_STREAM);
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
int zero = 0;
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (
|
|
|
|
zmq_setsockopt (stream, ZMQ_LINGER, &zero, sizeof (zero)));
|
2015-01-23 15:25:40 +01:00
|
|
|
int enabled = 1;
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (
|
|
|
|
zmq_setsockopt (stream, ZMQ_STREAM_NOTIFY, &enabled, sizeof (enabled)));
|
|
|
|
bind_loopback_ipv4 (stream, my_endpoint, sizeof my_endpoint);
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// We'll be using this socket as the other peer
|
2018-08-20 17:44:16 +02:00
|
|
|
void *dealer = test_context_socket (ZMQ_DEALER);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (
|
|
|
|
zmq_setsockopt (dealer, ZMQ_LINGER, &zero, sizeof (zero)));
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (dealer, my_endpoint));
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// Send a message on the dealer socket
|
2018-08-20 17:44:16 +02:00
|
|
|
send_string_expect_success (dealer, "Hello", 0);
|
2013-06-27 20:47:34 +02:00
|
|
|
|
2014-01-17 23:21:42 +01:00
|
|
|
// Connecting sends a zero message
|
2017-09-07 11:21:13 +02:00
|
|
|
// First frame is routing id
|
|
|
|
zmq_msg_t routing_id;
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init (&routing_id));
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&routing_id, stream, 0));
|
|
|
|
TEST_ASSERT_TRUE (zmq_msg_more (&routing_id));
|
2013-06-27 20:47:34 +02:00
|
|
|
|
2015-07-19 16:11:22 +02:00
|
|
|
// Verify the existence of Peer-Address metadata
|
2017-09-07 11:21:13 +02:00
|
|
|
char const *peer_address = zmq_msg_gets (&routing_id, "Peer-Address");
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_NOT_NULL (peer_address);
|
|
|
|
TEST_ASSERT_EQUAL_STRING ("127.0.0.1", peer_address);
|
2015-02-18 12:28:58 -06:00
|
|
|
|
2014-01-17 23:21:42 +01:00
|
|
|
// Second frame is zero
|
2018-02-01 11:46:09 +01:00
|
|
|
byte buffer[255];
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_EQUAL_INT (
|
|
|
|
0, TEST_ASSERT_SUCCESS_ERRNO (zmq_recv (stream, buffer, 255, 0)));
|
2015-02-18 12:28:58 -06:00
|
|
|
|
2015-07-19 16:11:22 +02:00
|
|
|
// Verify the existence of Peer-Address metadata
|
2017-09-07 11:21:13 +02:00
|
|
|
peer_address = zmq_msg_gets (&routing_id, "Peer-Address");
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_NOT_NULL (peer_address);
|
|
|
|
TEST_ASSERT_EQUAL_STRING ("127.0.0.1", peer_address);
|
2015-02-19 13:22:32 -06:00
|
|
|
|
2014-01-17 23:21:42 +01:00
|
|
|
// Real data follows
|
2017-09-07 11:21:13 +02:00
|
|
|
// First frame is routing id
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&routing_id, stream, 0));
|
|
|
|
TEST_ASSERT_TRUE (zmq_msg_more (&routing_id));
|
2014-01-17 23:21:42 +01:00
|
|
|
|
2015-07-19 16:11:22 +02:00
|
|
|
// Verify the existence of Peer-Address metadata
|
2017-09-07 11:21:13 +02:00
|
|
|
peer_address = zmq_msg_gets (&routing_id, "Peer-Address");
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_NOT_NULL (peer_address);
|
|
|
|
TEST_ASSERT_EQUAL_STRING ("127.0.0.1", peer_address);
|
2015-02-18 12:28:58 -06:00
|
|
|
|
2015-02-18 13:05:05 -06:00
|
|
|
// Second frame is greeting signature
|
2018-08-20 17:44:16 +02:00
|
|
|
recv_array_expect_success (stream, greeting.signature, 0);
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// Send our own protocol greeting
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_send (&routing_id, stream, ZMQ_SNDMORE));
|
|
|
|
TEST_ASSERT_EQUAL_INT (
|
|
|
|
sizeof (greeting), TEST_ASSERT_SUCCESS_ERRNO (
|
|
|
|
zmq_send (stream, &greeting, sizeof (greeting), 0)));
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// Now we expect the data from the DEALER socket
|
2013-10-23 23:58:39 +02:00
|
|
|
// We want the rest of greeting along with the Ready command
|
2013-09-06 09:22:09 +02:00
|
|
|
int bytes_read = 0;
|
|
|
|
while (bytes_read < 97) {
|
2017-09-07 11:21:13 +02:00
|
|
|
// First frame is the routing id of the connection (each time)
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_GREATER_THAN_INT (
|
|
|
|
0, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&routing_id, stream, 0)));
|
|
|
|
TEST_ASSERT_TRUE (zmq_msg_more (&routing_id));
|
2013-10-23 23:58:39 +02:00
|
|
|
// Second frame contains the next chunk of data
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (
|
|
|
|
rc = zmq_recv (stream, buffer + bytes_read, 255 - bytes_read, 0));
|
2013-09-06 09:22:09 +02:00
|
|
|
bytes_read += rc;
|
|
|
|
}
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// First two bytes are major and minor version numbers.
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_EQUAL_INT (3, buffer[0]); // ZMTP/3.0
|
|
|
|
TEST_ASSERT_EQUAL_INT (0, buffer[1]);
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// Mechanism is "NULL"
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_EQUAL_INT8_ARRAY (buffer + 2,
|
|
|
|
"NULL\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 20);
|
|
|
|
TEST_ASSERT_EQUAL_INT8_ARRAY (buffer + 54, "\4\51\5READY", 8);
|
|
|
|
TEST_ASSERT_EQUAL_INT8_ARRAY (buffer + 62, "\13Socket-Type\0\0\0\6DEALER",
|
|
|
|
22);
|
|
|
|
TEST_ASSERT_EQUAL_INT8_ARRAY (buffer + 84, "\10Identity\0\0\0\0", 13);
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// Announce we are ready
|
2013-09-04 17:59:45 +02:00
|
|
|
memcpy (buffer, "\4\51\5READY", 8);
|
2013-07-01 10:04:54 +02:00
|
|
|
memcpy (buffer + 8, "\13Socket-Type\0\0\0\6ROUTER", 22);
|
2013-06-28 11:42:54 +02:00
|
|
|
memcpy (buffer + 30, "\10Identity\0\0\0\0", 13);
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// Send Ready command
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_GREATER_THAN_INT (0, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_send (
|
|
|
|
&routing_id, stream, ZMQ_SNDMORE)));
|
|
|
|
TEST_ASSERT_EQUAL_INT (
|
|
|
|
43, TEST_ASSERT_SUCCESS_ERRNO (zmq_send (stream, buffer, 43, 0)));
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// Now we expect the data from the DEALER socket
|
2017-09-07 11:21:13 +02:00
|
|
|
// First frame is, again, the routing id of the connection
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_GREATER_THAN_INT (
|
|
|
|
0, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&routing_id, stream, 0)));
|
|
|
|
TEST_ASSERT_TRUE (zmq_msg_more (&routing_id));
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// Third frame contains Hello message from DEALER
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_EQUAL_INT (7, TEST_ASSERT_SUCCESS_ERRNO (
|
|
|
|
zmq_recv (stream, buffer, sizeof buffer, 0)));
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// Then we have a 5-byte message "Hello"
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_EQUAL_INT (0, buffer[0]); // Flags = 0
|
|
|
|
TEST_ASSERT_EQUAL_INT (5, buffer[1]); // Size = 5
|
|
|
|
TEST_ASSERT_EQUAL_INT8_ARRAY (buffer + 2, "Hello", 5);
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// Send "World" back to DEALER
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_GREATER_THAN_INT (0, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_send (
|
|
|
|
&routing_id, stream, ZMQ_SNDMORE)));
|
2018-02-01 11:46:09 +01:00
|
|
|
byte world[] = {0, 5, 'W', 'o', 'r', 'l', 'd'};
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_EQUAL_INT (
|
|
|
|
sizeof (world),
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_send (stream, world, sizeof (world), 0)));
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// Expect response on DEALER socket
|
2018-08-20 17:44:16 +02:00
|
|
|
recv_string_expect_success (dealer, "World", 0);
|
2013-06-27 20:47:34 +02:00
|
|
|
|
2015-07-19 16:11:22 +02:00
|
|
|
// Test large messages over STREAM socket
|
2018-02-01 11:46:09 +01:00
|
|
|
#define size 64000
|
|
|
|
uint8_t msgout[size];
|
2015-07-19 16:11:22 +02:00
|
|
|
memset (msgout, 0xAB, size);
|
|
|
|
zmq_send (dealer, msgout, size, 0);
|
|
|
|
|
2018-02-01 11:46:09 +01:00
|
|
|
uint8_t msgin[9 + size];
|
2015-07-19 16:11:22 +02:00
|
|
|
memset (msgin, 0, 9 + size);
|
|
|
|
bytes_read = 0;
|
|
|
|
while (bytes_read < 9 + size) {
|
2017-09-07 11:21:13 +02:00
|
|
|
// Get routing id frame
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_GREATER_THAN_INT (
|
|
|
|
0, TEST_ASSERT_SUCCESS_ERRNO (zmq_recv (stream, buffer, 256, 0)));
|
2015-07-19 16:11:22 +02:00
|
|
|
// Get next chunk
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_GREATER_THAN_INT (
|
|
|
|
0,
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (rc = zmq_recv (stream, msgin + bytes_read,
|
|
|
|
9 + size - bytes_read, 0)));
|
2015-07-19 16:11:22 +02:00
|
|
|
bytes_read += rc;
|
|
|
|
}
|
2018-08-20 17:44:16 +02:00
|
|
|
for (int byte_nbr = 0; byte_nbr < size; byte_nbr++) {
|
|
|
|
TEST_ASSERT_EQUAL_UINT8 (0xAB, msgin[9 + byte_nbr]);
|
2015-07-19 16:11:22 +02:00
|
|
|
}
|
2018-08-20 17:44:16 +02:00
|
|
|
test_context_socket_close (dealer);
|
|
|
|
test_context_socket_close (stream);
|
2013-06-27 20:47:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-20 17:44:16 +02:00
|
|
|
static void test_stream_to_stream ()
|
2013-06-27 20:47:34 +02:00
|
|
|
{
|
2017-05-01 12:11:11 +01:00
|
|
|
char my_endpoint[MAX_SOCKET_STRING];
|
2013-06-27 20:47:34 +02:00
|
|
|
// Set-up our context and sockets
|
2015-02-18 12:28:58 -06:00
|
|
|
|
2018-08-20 17:44:16 +02:00
|
|
|
void *server = test_context_socket (ZMQ_STREAM);
|
2015-01-23 15:25:40 +01:00
|
|
|
int enabled = 1;
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (
|
|
|
|
zmq_setsockopt (server, ZMQ_STREAM_NOTIFY, &enabled, sizeof (enabled)));
|
|
|
|
bind_loopback_ipv4 (server, my_endpoint, sizeof my_endpoint);
|
|
|
|
|
|
|
|
void *client = test_context_socket (ZMQ_STREAM);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (
|
|
|
|
zmq_setsockopt (client, ZMQ_STREAM_NOTIFY, &enabled, sizeof (enabled)));
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (client, my_endpoint));
|
2018-02-01 11:46:09 +01:00
|
|
|
uint8_t id[256];
|
|
|
|
uint8_t buffer[256];
|
2015-02-18 12:28:58 -06:00
|
|
|
|
2014-01-17 23:21:42 +01:00
|
|
|
// Connecting sends a zero message
|
2017-09-07 11:21:13 +02:00
|
|
|
// Server: First frame is routing id, second frame is zero
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_GREATER_THAN_INT (
|
|
|
|
0, TEST_ASSERT_SUCCESS_ERRNO (zmq_recv (server, id, 256, 0)));
|
|
|
|
TEST_ASSERT_EQUAL_INT (
|
|
|
|
0, TEST_ASSERT_SUCCESS_ERRNO (zmq_recv (server, buffer, 256, 0)));
|
2017-09-07 11:21:13 +02:00
|
|
|
// Client: First frame is routing id, second frame is zero
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_GREATER_THAN_INT (
|
|
|
|
0, TEST_ASSERT_SUCCESS_ERRNO (zmq_recv (client, id, 256, 0)));
|
|
|
|
TEST_ASSERT_EQUAL_INT (
|
|
|
|
0, TEST_ASSERT_SUCCESS_ERRNO (zmq_recv (client, buffer, 256, 0)));
|
2014-01-17 23:21:42 +01:00
|
|
|
|
2013-06-27 20:47:34 +02:00
|
|
|
// Sent HTTP request on client socket
|
2017-09-07 11:21:13 +02:00
|
|
|
// Get server routing id
|
2018-08-20 17:44:16 +02:00
|
|
|
size_t id_size = sizeof id;
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (
|
|
|
|
zmq_getsockopt (client, ZMQ_ROUTING_ID, id, &id_size));
|
2017-09-07 11:21:13 +02:00
|
|
|
// First frame is server routing id
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_EQUAL_INT ((int) id_size, TEST_ASSERT_SUCCESS_ERRNO (zmq_send (
|
|
|
|
client, id, id_size, ZMQ_SNDMORE)));
|
2013-06-27 20:47:34 +02:00
|
|
|
// Second frame is HTTP GET request
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_EQUAL_INT (
|
|
|
|
7, TEST_ASSERT_SUCCESS_ERRNO (zmq_send (client, "GET /\n\n", 7, 0)));
|
2015-02-18 12:28:58 -06:00
|
|
|
|
2013-06-27 20:47:34 +02:00
|
|
|
// Get HTTP request; ID frame and then request
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_GREATER_THAN_INT (
|
|
|
|
0, TEST_ASSERT_SUCCESS_ERRNO (zmq_recv (server, id, 256, 0)));
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_recv (server, buffer, 256, 0));
|
|
|
|
TEST_ASSERT_EQUAL_INT8_ARRAY (buffer, "GET /\n\n", 7);
|
2015-02-18 12:28:58 -06:00
|
|
|
|
2013-06-27 20:47:34 +02:00
|
|
|
// Send reply back to client
|
2018-02-01 11:46:09 +01:00
|
|
|
char http_response[] = "HTTP/1.0 200 OK\r\n"
|
|
|
|
"Content-Type: text/plain\r\n"
|
|
|
|
"\r\n"
|
|
|
|
"Hello, World!";
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_send (server, id, id_size, ZMQ_SNDMORE));
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (
|
|
|
|
zmq_send (server, http_response, sizeof (http_response), ZMQ_SNDMORE));
|
2014-01-17 23:21:42 +01:00
|
|
|
|
|
|
|
// Send zero to close connection to client
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_send (server, id, id_size, ZMQ_SNDMORE));
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_send (server, NULL, 0, ZMQ_SNDMORE));
|
2013-06-27 20:47:34 +02:00
|
|
|
|
|
|
|
// Get reply at client and check that it's complete
|
2018-08-20 17:44:16 +02:00
|
|
|
TEST_ASSERT_GREATER_THAN_INT (
|
|
|
|
0, TEST_ASSERT_SUCCESS_ERRNO (zmq_recv (client, id, 256, 0)));
|
|
|
|
TEST_ASSERT_EQUAL_INT (
|
|
|
|
sizeof http_response,
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_recv (client, buffer, 256, 0)));
|
|
|
|
TEST_ASSERT_EQUAL_INT8_ARRAY (buffer, http_response,
|
|
|
|
sizeof (http_response));
|
2014-01-17 23:21:42 +01:00
|
|
|
|
|
|
|
// // Get disconnection notification
|
|
|
|
// FIXME: why does this block? Bug in STREAM disconnect notification?
|
|
|
|
// id_size = zmq_recv (client, id, 256, 0);
|
|
|
|
// assert (id_size > 0);
|
|
|
|
// rc = zmq_recv (client, buffer, 256, 0);
|
|
|
|
// assert (rc == 0);
|
|
|
|
|
2018-08-20 17:44:16 +02:00
|
|
|
test_context_socket_close (server);
|
|
|
|
test_context_socket_close (client);
|
2013-06-27 20:47:34 +02:00
|
|
|
}
|
|
|
|
|
2018-08-20 17:44:16 +02:00
|
|
|
int main ()
|
2013-06-27 20:47:34 +02:00
|
|
|
{
|
2018-02-01 11:46:09 +01:00
|
|
|
setup_test_environment ();
|
2018-08-20 17:44:16 +02:00
|
|
|
|
|
|
|
UNITY_BEGIN ();
|
|
|
|
RUN_TEST (test_stream_to_dealer);
|
|
|
|
RUN_TEST (test_stream_to_stream);
|
|
|
|
return UNITY_END ();
|
2013-07-01 10:04:54 +02:00
|
|
|
}
|