Unverified Commit 6d77558c authored by Luca Boccassi's avatar Luca Boccassi Committed by GitHub

Merge pull request #3459 from sigiesec/migrate-testutil

Migrate testutil* to Unity, and build testutil as separate library
parents f4b9cc99 c2cd2966
......@@ -7,6 +7,7 @@ doc/Makefile
Makefile.in
configure
libtool
libtestutil.a
libunity.a
config
config.status
......
This diff is collapsed.
......@@ -33,6 +33,7 @@
#if !defined ZMQ_HAVE_WINDOWS
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#endif
#include "address.hpp"
......
......@@ -136,7 +136,7 @@ zmq::socks_request_t::socks_request_t (uint8_t command_,
hostname (ZMQ_MOVE (hostname_)),
port (port_)
{
zmq_assert (hostname_.size () <= UINT8_MAX);
zmq_assert (hostname.size () <= UINT8_MAX);
}
zmq::socks_request_encoder_t::socks_request_encoder_t () :
......
......@@ -297,13 +297,20 @@ void zmq::stream_engine_t::terminate ()
}
void zmq::stream_engine_t::in_event ()
{
// ignore errors
const bool res = in_event_internal ();
LIBZMQ_UNUSED (res);
}
bool zmq::stream_engine_t::in_event_internal ()
{
zmq_assert (!_io_error);
// If still handshaking, receive and process the greeting message.
if (unlikely (_handshaking))
if (!handshake ())
return;
return false;
zmq_assert (_decoder);
......@@ -311,7 +318,7 @@ void zmq::stream_engine_t::in_event ()
if (_input_stopped) {
rm_fd (_handle);
_io_error = true;
return;
return true; // TODO or return false in this case too?
}
// If there's no data to process in the buffer...
......@@ -329,12 +336,14 @@ void zmq::stream_engine_t::in_event ()
// connection closed by peer
errno = EPIPE;
error (connection_error);
return;
return false;
}
if (rc == -1) {
if (errno != EAGAIN)
if (errno != EAGAIN) {
error (connection_error);
return;
return false;
}
return true;
}
// Adjust input size
......@@ -363,13 +372,14 @@ void zmq::stream_engine_t::in_event ()
if (rc == -1) {
if (errno != EAGAIN) {
error (protocol_error);
return;
return false;
}
_input_stopped = true;
reset_pollin (_handle);
}
_session->flush ();
return true;
}
void zmq::stream_engine_t::out_event ()
......@@ -497,7 +507,8 @@ bool zmq::stream_engine_t::restart_input ()
_session->flush ();
// Speculative read.
in_event ();
if (!in_event_internal ())
return false;
}
return true;
......
......@@ -87,6 +87,8 @@ class stream_engine_t : public io_object_t, public i_engine
void timer_event (int id_);
private:
bool in_event_internal ();
// Unplug the engine from the session.
void unplug ();
......
......@@ -75,6 +75,11 @@ set(tests
test_mock_pub_sub
)
if(NOT WIN32)
list(APPEND tests
test_security_gssapi)
endif()
if(ZMQ_HAVE_CURVE)
list(APPEND tests
test_security_curve)
......@@ -168,6 +173,32 @@ set_target_properties(unity PROPERTIES
target_compile_definitions(unity PUBLIC "UNITY_USE_COMMAND_LINE_ARGS" "UNITY_EXCLUDE_FLOAT")
target_include_directories(unity PUBLIC "${CMAKE_CURRENT_LIST_DIR}/../external/unity")
set(TESTUTIL_SOURCES
testutil.cpp
testutil.hpp
testutil_monitoring.cpp
testutil_monitoring.hpp
testutil_security.cpp
testutil_security.hpp
testutil_unity.cpp
testutil_unity.hpp
)
if(BUILD_STATIC)
add_library(testutil-static STATIC ${TESTUTIL_SOURCES})
target_link_libraries(testutil-static libzmq-static ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} unity)
endif()
if(BUILD_SHARED)
add_library(testutil STATIC ${TESTUTIL_SOURCES})
target_link_libraries(testutil libzmq ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} unity)
endif()
if(BUILD_STATIC AND NOT BUILD_SHARED)
# use testutil-static for both tests and unit tests
set(TESTUTIL_LIB testutil-static)
else()
# use testutil for tests and testutil-static for unit tests
set(TESTUTIL_LIB testutil)
endif()
if(MSVC_VERSION LESS 1700)
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.c" PROPERTIES LANGUAGE CXX)
endif()
......@@ -176,13 +207,11 @@ if(MSVC_VERSION LESS 1600)
target_compile_definitions(unity PUBLIC "UNITY_EXCLUDE_STDINT_H")
endif()
# add library and include dirs for all targets
if(BUILD_SHARED)
link_libraries(libzmq ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} unity)
else()
link_libraries(libzmq-static ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} unity)
endif()
# add include dirs for all targets
include_directories("${ZeroMQ_SOURCE_DIR}/../include" "${ZeroMQ_BINARY_DIR}")
if(WIN32)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
endif()
foreach(test ${tests})
# target_sources not supported before CMake 3.1
......@@ -191,14 +220,11 @@ foreach(test ${tests})
"../src/tweetnacl.c"
"../src/err.cpp"
"../src/random.cpp"
"../src/clock.cpp"
"testutil_security.hpp")
elseif(${test} MATCHES test_security_zap)
add_executable(${test} ${test}.cpp
"testutil_security.hpp")
"../src/clock.cpp")
else()
add_executable(${test} ${test}.cpp "testutil.hpp" "testutil_unity.hpp" "testutil_monitoring.hpp")
add_executable(${test} ${test}.cpp)
endif()
target_link_libraries(${test} ${TESTUTIL_LIB})
if(WIN32)
# This is the output for Debug dynamic builds on Visual Studio 6.0
# You should provide the correct directory, don't know how to do it automatically
......
......@@ -30,6 +30,7 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
#include <unity.h>
void setUp ()
......
......@@ -57,7 +57,7 @@ void test_version ()
void test_strerrror ()
{
assert (zmq_strerror (EINVAL));
TEST_ASSERT_NOT_NULL (zmq_strerror (EINVAL));
}
int main ()
......
......@@ -31,6 +31,7 @@
#include "testutil_unity.hpp"
#include <unity.h>
#include <string.h>
void setUp ()
{
......
......@@ -30,6 +30,8 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
void setUp ()
{
setup_test_context ();
......
......@@ -44,7 +44,8 @@ static void receiver (void *socket_)
{
char buffer[16];
int rc = zmq_recv (socket_, &buffer, sizeof (buffer), 0);
assert (rc == -1);
// TODO which error is expected here? use TEST_ASSERT_FAILURE_ERRNO instead
TEST_ASSERT_EQUAL_INT (-1, rc);
}
void test_ctx_destroy ()
......
This diff is collapsed.
......@@ -30,6 +30,8 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <string.h>
#include <unity.h>
void setUp ()
......
......@@ -28,46 +28,43 @@
*/
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
void setUp ()
{
setup_test_context ();
}
void tearDown ()
{
teardown_test_context ();
}
/// Initialize a zeromq message with a given null-terminated string
#define ZMQ_PREPARE_STRING(msg, data, size) \
\
zmq_msg_init (&msg) \
&& printf ("zmq_msg_init: %s\n", zmq_strerror (errno)); \
\
zmq_msg_init_size (&msg, size + 1) \
&& printf ("zmq_msg_init_size: %s\n", zmq_strerror (errno)); \
\
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init (&msg)); \
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init_size (&msg, size + 1)); \
memcpy (zmq_msg_data (&msg), data, size + 1);
// TODO: this code fails to meet our style guidelines, and needs rewriting
static int publicationsReceived = 0;
static bool isSubscribed = false;
int main (int, char **)
void test_disconnect_inproc ()
{
setup_test_environment ();
void *context = zmq_ctx_new ();
void *pub_socket;
void *sub_socket;
(pub_socket = zmq_socket (context, ZMQ_XPUB))
|| printf ("zmq_socket: %s\n", zmq_strerror (errno));
(sub_socket = zmq_socket (context, ZMQ_SUB))
|| printf ("zmq_socket: %s\n", zmq_strerror (errno));
zmq_setsockopt (sub_socket, ZMQ_SUBSCRIBE, "foo", 3)
&& printf ("zmq_setsockopt: %s\n", zmq_strerror (errno));
void *pub_socket = test_context_socket (ZMQ_XPUB);
void *sub_socket = test_context_socket (ZMQ_SUB);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_setsockopt (sub_socket, ZMQ_SUBSCRIBE, "foo", 3));
zmq_bind (pub_socket, "inproc://someInProcDescriptor")
&& printf ("zmq_bind: %s\n", zmq_strerror (errno));
//zmq_bind(pubSocket, "tcp://127.0.0.1:30010") && printf("zmq_bind: %s\n", zmq_strerror(errno));
TEST_ASSERT_SUCCESS_ERRNO (
zmq_bind (pub_socket, "inproc://someInProcDescriptor"));
int more;
size_t more_size = sizeof (more);
int iteration = 0;
while (1) {
for (int iteration = 0;; ++iteration) {
zmq_pollitem_t items[] = {
{sub_socket, 0, ZMQ_POLLIN, 0}, // read publications
{pub_socket, 0, ZMQ_POLLIN, 0}, // read subscriptions
......@@ -75,77 +72,73 @@ int main (int, char **)
int rc = zmq_poll (items, 2, 100);
if (items[1].revents & ZMQ_POLLIN) {
while (1) {
for (more = 1; more;) {
zmq_msg_t msg;
zmq_msg_init (&msg);
zmq_msg_recv (&msg, pub_socket, 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, pub_socket, 0));
char *buffer = (char *) zmq_msg_data (&msg);
if (buffer[0] == 0) {
assert (isSubscribed);
TEST_ASSERT_TRUE (isSubscribed);
isSubscribed = false;
} else {
assert (!isSubscribed);
TEST_ASSERT_FALSE (isSubscribed);
isSubscribed = true;
}
zmq_getsockopt (pub_socket, ZMQ_RCVMORE, &more, &more_size);
zmq_msg_close (&msg);
if (!more)
break; // Last message part
TEST_ASSERT_SUCCESS_ERRNO (
zmq_getsockopt (pub_socket, ZMQ_RCVMORE, &more, &more_size));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&msg));
}
}
if (items[0].revents & ZMQ_POLLIN) {
while (1) {
more = 1;
for (more = 1; more;) {
zmq_msg_t msg;
zmq_msg_init (&msg);
zmq_msg_recv (&msg, sub_socket, 0);
zmq_getsockopt (sub_socket, ZMQ_RCVMORE, &more, &more_size);
zmq_msg_close (&msg);
if (!more) {
publicationsReceived++;
break; // Last message part
}
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init (&msg));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, sub_socket, 0));
TEST_ASSERT_SUCCESS_ERRNO (
zmq_getsockopt (sub_socket, ZMQ_RCVMORE, &more, &more_size));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&msg));
}
publicationsReceived++;
}
if (iteration == 1) {
zmq_connect (sub_socket, "inproc://someInProcDescriptor")
&& printf ("zmq_connect: %s\n", zmq_strerror (errno));
TEST_ASSERT_SUCCESS_ERRNO (
zmq_connect (sub_socket, "inproc://someInProcDescriptor"));
msleep (SETTLE_TIME);
}
if (iteration == 4) {
zmq_disconnect (sub_socket, "inproc://someInProcDescriptor")
&& printf ("zmq_disconnect(%d): %s\n", errno,
zmq_strerror (errno));
TEST_ASSERT_SUCCESS_ERRNO (
zmq_disconnect (sub_socket, "inproc://someInProcDescriptor"));
}
if (iteration > 4 && rc == 0)
break;
zmq_msg_t channel_envlp;
ZMQ_PREPARE_STRING (channel_envlp, "foo", 3);
zmq_msg_send (&channel_envlp, pub_socket, ZMQ_SNDMORE) >= 0
|| printf ("zmq_msg_send: %s\n", zmq_strerror (errno));
zmq_msg_close (&channel_envlp)
&& printf ("zmq_msg_close: %s\n", zmq_strerror (errno));
TEST_ASSERT_SUCCESS_ERRNO (
zmq_msg_send (&channel_envlp, pub_socket, ZMQ_SNDMORE));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&channel_envlp));
zmq_msg_t message;
ZMQ_PREPARE_STRING (message, "this is foo!", 12);
zmq_msg_send (&message, pub_socket, 0) >= 0
|| printf ("zmq_msg_send: %s\n", zmq_strerror (errno));
zmq_msg_close (&message)
&& printf ("zmq_msg_close: %s\n", zmq_strerror (errno));
iteration++;
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_send (&message, pub_socket, 0));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&message));
}
assert (publicationsReceived == 3);
assert (!isSubscribed);
TEST_ASSERT_EQUAL_INT (3, publicationsReceived);
TEST_ASSERT_FALSE (isSubscribed);
zmq_close (pub_socket) && printf ("zmq_close: %s", zmq_strerror (errno));
zmq_close (sub_socket) && printf ("zmq_close: %s", zmq_strerror (errno));
test_context_socket_close (pub_socket);
test_context_socket_close (sub_socket);
}
int main (int, char **)
{
setup_test_environment ();
zmq_ctx_term (context);
return 0;
UNITY_BEGIN ();
RUN_TEST (test_disconnect_inproc);
return UNITY_END ();
}
......@@ -30,6 +30,9 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <unistd.h>
#include <grp.h>
void setUp ()
{
setup_test_context ();
......@@ -117,7 +120,7 @@ void init_groups ()
// Get the group and supplemental groups of the process owner
gid_t groups[100];
int ngroups = getgroups (100, groups);
assert (ngroups != -1);
TEST_ASSERT_NOT_EQUAL (-1, ngroups);
group = getgid ();
supgroup = group;
notgroup = group + 1;
......
......@@ -28,41 +28,50 @@
*/
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
void setUp ()
{
setup_test_context ();
}
void tearDown ()
{
teardown_test_context ();
}
const char *address = "tcp://127.0.0.1:*";
char connect_address[MAX_SOCKET_STRING];
#define NUM_MESSAGES 5
int main (void)
void test_fork ()
{
#if !defined(ZMQ_HAVE_WINDOWS)
setup_test_environment ();
void *ctx = zmq_ctx_new ();
assert (ctx);
// Create and bind pull socket to receive messages
void *pull = zmq_socket (ctx, ZMQ_PULL);
assert (pull);
int rc = zmq_bind (pull, address);
assert (rc == 0);
size_t len = MAX_SOCKET_STRING;
rc = zmq_getsockopt (pull, ZMQ_LAST_ENDPOINT, connect_address, &len);
assert (rc == 0);
void *pull = test_context_socket (ZMQ_PULL);
bind_loopback_ipv4 (pull, connect_address, sizeof connect_address);
int pid = fork ();
if (pid == 0) {
// use regular assertions in the child process
// Child process
// Immediately close parent sockets and context
zmq_close (pull);
zmq_ctx_term (ctx);
zmq_ctx_term (get_test_context ());
// Create new context, socket, connect and send some messages
void *child_ctx = zmq_ctx_new ();
assert (child_ctx);
void *push = zmq_socket (child_ctx, ZMQ_PUSH);
assert (push);
rc = zmq_connect (push, connect_address);
int rc = zmq_connect (push, connect_address);
assert (rc == 0);
int count;
for (count = 0; count < NUM_MESSAGES; count++)
......@@ -75,24 +84,28 @@ int main (void)
// Parent process
int count;
for (count = 0; count < NUM_MESSAGES; count++) {
char buffer[5];
int num_bytes = zmq_recv (pull, buffer, 5, 0);
assert (num_bytes == 5);
recv_string_expect_success (pull, "Hello", 0);
}
int child_status;
while (true) {
rc = waitpid (pid, &child_status, 0);
int rc = waitpid (pid, &child_status, 0);
if (rc == -1 && errno == EINTR)
continue;
assert (rc > 0);
TEST_ASSERT_GREATER_THAN (0, rc);
// Verify the status code of the child was zero
assert (WEXITSTATUS (child_status) == 0);
TEST_ASSERT_EQUAL (0, WEXITSTATUS (child_status));
break;
}
zmq_close (pull);
zmq_ctx_term (ctx);
exit (0);
test_context_socket_close (pull);
}
#endif
return 0;
}
int main (void)
{
setup_test_environment ();
UNITY_BEGIN ();
RUN_TEST (test_fork);
return UNITY_END ();
}
......@@ -23,42 +23,46 @@
*/
#include "testutil.hpp"
#include "testutil_unity.hpp"
int main (void)
#include <string.h>
void setUp ()
{
setup_test_context ();
}
void tearDown ()
{
teardown_test_context ();
}
void test_getsockopt_memset ()
{
int64_t more;
size_t more_size = sizeof (more);
setup_test_environment ();
void *ctx = zmq_ctx_new ();
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_PUB);
assert (sb);
int rc = zmq_bind (sb, "inproc://a");
assert (rc == 0);
void *sb = test_context_socket (ZMQ_PUB);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, "inproc://a"));
void *sc = zmq_socket (ctx, ZMQ_SUB);
assert (sc);
rc = zmq_connect (sc, "inproc://a");
assert (rc == 0);
void *sc = test_context_socket (ZMQ_SUB);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, "inproc://a"));
memset (&more, 0xFF, sizeof (int64_t));
zmq_getsockopt (sc, ZMQ_RCVMORE, &more, &more_size);
assert (more_size == sizeof (int));
assert (more == 0);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_getsockopt (sc, ZMQ_RCVMORE, &more, &more_size));
TEST_ASSERT_EQUAL_INT (sizeof (int), more_size);
TEST_ASSERT_EQUAL_INT (0, more);
// Cleanup
test_context_socket_close (sc);
test_context_socket_close (sb);
}
rc = zmq_close (sc);
assert (rc == 0);
rc = zmq_close (sb);
assert (rc == 0);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
int main (void)
{
setup_test_environment ();
return 0;
UNITY_BEGIN ();
RUN_TEST (test_getsockopt_memset);
return UNITY_END ();
}
......@@ -26,10 +26,13 @@
typedef SOCKET raw_socket;
#else
#include <arpa/inet.h>
#include <unistd.h>
typedef int raw_socket;
#endif
#include <limits.h>
#include <stdlib.h>
#include <string.h>
// TODO remove this here, either ensure that UINT16_MAX is always properly
// defined or handle this at a more central location
......
......@@ -191,12 +191,8 @@ int test_inproc_connect_and_close_first (int send_hwm_, int recv_hwm_)
int test_inproc_bind_and_close_first (int send_hwm_, int /* recv_hwm */)
{
void *ctx = zmq_ctx_new ();
TEST_ASSERT_NOT_NULL (ctx);
// Set up bind socket
void *bind_socket = zmq_socket (ctx, ZMQ_PUSH);
TEST_ASSERT_NOT_NULL (bind_socket);
void *bind_socket = test_context_socket (ZMQ_PUSH);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_setsockopt (bind_socket, ZMQ_SNDHWM, &send_hwm_, sizeof (send_hwm_)));
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (bind_socket, "inproc://a"));
......@@ -208,12 +204,11 @@ int test_inproc_bind_and_close_first (int send_hwm_, int /* recv_hwm */)
++send_count;
// Close bind
TEST_ASSERT_SUCCESS_ERRNO (zmq_close (bind_socket));
test_context_socket_close (bind_socket);
/* TODO Can't currently do connect without then wiring up a bind as things hang, this needs top be fixed.
// Set up connect socket
void *connect_socket = zmq_socket (ctx, ZMQ_PULL);
TEST_ASSERT_NOT_NULL(connect_socket);
void *connect_socket = test_context_socket (ZMQ_PULL);
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (connect_socket, ZMQ_RCVHWM, &recv_hwm, sizeof (recv_hwm)));
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connect_socket, "inproc://a"));
......@@ -226,9 +221,7 @@ int test_inproc_bind_and_close_first (int send_hwm_, int /* recv_hwm */)
*/
// Clean up
//TEST_ASSERT_SUCCESS_ERRNO (zmq_close (connect_socket));
TEST_ASSERT_SUCCESS_ERRNO (zmq_ctx_term (ctx));
//test_context_socket_close (connect_socket);
return send_count;
}
......
......@@ -30,6 +30,8 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
// NOTE: on OSX the endpoint returned by ZMQ_LAST_ENDPOINT may be quite long,
// ensure we have extra space for that:
#define SOCKET_STRING_LEN (MAX_SOCKET_STRING * 4)
......
......@@ -30,6 +30,8 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <string.h>
#include <unity.h>
void setUp ()
......@@ -55,7 +57,9 @@ struct iovec
static void do_check (void *sb_, void *sc_, size_t msg_size_)
{
assert (sb_ && sc_ && msg_size_ > 0);
TEST_ASSERT_NOT_NULL (sb_);
TEST_ASSERT_NOT_NULL (sc_);
TEST_ASSERT_GREATER_THAN (0, msg_size_);
const char msg_val = '1';
const int num_messages = 10;
......@@ -76,8 +80,8 @@ static void do_check (void *sb_, void *sc_, size_t msg_size_)
send_iov[i].iov_len = msg_size_;
memcpy (send_iov[i].iov_base, ref_msg, msg_size_);
// TODO: this assertion only checks if memcpy behaves as expected... remove this?
assert (memcmp (ref_msg, send_iov[i].iov_base, msg_size_) == 0);
// TODO: this assertion only checks if memcpy behaves as expected... remove this or assert something else?
TEST_ASSERT_EQUAL_HEX8_ARRAY (ref_msg, send_iov[i].iov_base, msg_size_);
}
// Test errors - zmq_recviov - null socket
......
......@@ -44,12 +44,12 @@ void tearDown ()
static void do_bind_and_verify (void *s_, const char *endpoint_)
{
int rc = zmq_bind (s_, endpoint_);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (s_, endpoint_));
char reported[255];
size_t size = 255;
rc = zmq_getsockopt (s_, ZMQ_LAST_ENDPOINT, reported, &size);
assert (rc == 0 && strcmp (reported, endpoint_) == 0);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_getsockopt (s_, ZMQ_LAST_ENDPOINT, reported, &size));
TEST_ASSERT_EQUAL_STRING (endpoint_, reported);
}
void test_last_endpoint ()
......
......@@ -28,75 +28,81 @@
*/
#include "testutil.hpp"
#include <zmq.h>
#include "testutil_unity.hpp"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
void setUp ()
{
setup_test_context ();
}
void tearDown ()
{
teardown_test_context ();
}
void test_system_max ()
{
// Keep allocating sockets until we run out of system resources
const int no_of_sockets = 2 * 65536;
void *ctx = zmq_ctx_new ();
zmq_ctx_set (ctx, ZMQ_MAX_SOCKETS, no_of_sockets);
zmq_ctx_set (get_test_context (), ZMQ_MAX_SOCKETS, no_of_sockets);
std::vector<void *> sockets;
while (true) {
void *socket = zmq_socket (ctx, ZMQ_PAIR);
void *socket = zmq_socket (get_test_context (), ZMQ_PAIR);
if (!socket)
break;
sockets.push_back (socket);
}
assert (static_cast<int> (sockets.size ()) <= no_of_sockets);
TEST_ASSERT_LESS_OR_EQUAL (no_of_sockets,
static_cast<int> (sockets.size ()));
printf ("Socket creation failed after %i sockets\n",
static_cast<int> (sockets.size ()));
// System is out of resources, further calls to zmq_socket should return NULL
for (unsigned int i = 0; i < 10; ++i) {
void *socket = zmq_socket (ctx, ZMQ_PAIR);
assert (socket == NULL);
void *socket = zmq_socket (get_test_context (), ZMQ_PAIR);
TEST_ASSERT_NULL (socket);
}
// Clean up.
for (unsigned int i = 0; i < sockets.size (); ++i)
zmq_close (sockets[i]);
zmq_ctx_destroy (ctx);
TEST_ASSERT_SUCCESS_ERRNO (zmq_close (sockets[i]));
}
void test_zmq_default_max ()
{
// Keep allocating sockets until we hit the default limit
void *ctx = zmq_ctx_new ();
std::vector<void *> sockets;
while (true) {
void *socket = zmq_socket (ctx, ZMQ_PAIR);
void *socket = zmq_socket (get_test_context (), ZMQ_PAIR);
if (!socket)
break;
sockets.push_back (socket);
}
// We may stop sooner if system has fewer available sockets
assert (sockets.size () <= ZMQ_MAX_SOCKETS_DFLT);
TEST_ASSERT_LESS_OR_EQUAL (ZMQ_MAX_SOCKETS_DFLT, sockets.size ());
// Further calls to zmq_socket should return NULL
for (unsigned int i = 0; i < 10; ++i) {
void *socket = zmq_socket (ctx, ZMQ_PAIR);
assert (socket == NULL);
void *socket = zmq_socket (get_test_context (), ZMQ_PAIR);
TEST_ASSERT_NULL (socket);
}
// Clean up
for (unsigned int i = 0; i < sockets.size (); ++i)
zmq_close (sockets[i]);
zmq_ctx_destroy (ctx);
TEST_ASSERT_SUCCESS_ERRNO (zmq_close (sockets[i]));
}
int main (void)
{
setup_test_environment ();
test_system_max ();
test_zmq_default_max ();
return 0;
UNITY_BEGIN ();
RUN_TEST (test_system_max);
RUN_TEST (test_zmq_default_max);
return UNITY_END ();
}
......@@ -30,6 +30,7 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <unity.h>
void setUp ()
......@@ -57,8 +58,8 @@ static void zap_handler (void *handler_)
char *routing_id = s_recv (handler_);
char *mechanism = s_recv (handler_);
assert (streq (version, "1.0"));
assert (streq (mechanism, "NULL"));
TEST_ASSERT_EQUAL_STRING ("1.0", version);
TEST_ASSERT_EQUAL_STRING ("NULL", mechanism);
s_sendmore (handler_, version);
s_sendmore (handler_, sequence);
......
......@@ -27,9 +27,12 @@
typedef SOCKET raw_socket;
#else
#include <arpa/inet.h>
#include <unistd.h>
typedef int raw_socket;
#endif
#include <stdlib.h>
#include <string.h>
void setUp ()
{
......
......@@ -32,6 +32,9 @@
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <string.h>
void setUp ()
{
setup_test_context ();
......@@ -99,7 +102,7 @@ void test_monitor_basic ()
int event = get_monitor_event (client_mon, NULL, NULL);
if (event == ZMQ_EVENT_CONNECT_DELAYED)
event = get_monitor_event (client_mon, NULL, NULL);
assert (event == ZMQ_EVENT_CONNECTED);
TEST_ASSERT_EQUAL_INT (ZMQ_EVENT_CONNECTED, event);
expect_monitor_event (client_mon, ZMQ_EVENT_HANDSHAKE_SUCCEEDED);
event = get_monitor_event (client_mon, NULL, NULL);
if (event == ZMQ_EVENT_DISCONNECTED) {
......
......@@ -28,6 +28,19 @@
*/
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
void setUp ()
{
setup_test_context ();
}
void tearDown ()
{
teardown_test_context ();
}
void ffn (void *data_, void *hint_)
{
......@@ -36,29 +49,16 @@ void ffn (void *data_, void *hint_)
memcpy (hint_, (void *) "freed", 5);
}
int main (void)
void test_msg_ffn ()
{
setup_test_environment ();
// Create the infrastructure
void *ctx = zmq_ctx_new ();
assert (ctx);
size_t len = MAX_SOCKET_STRING;
char my_endpoint[MAX_SOCKET_STRING];
void *router = zmq_socket (ctx, ZMQ_ROUTER);
assert (router);
int rc = zmq_bind (router, "tcp://127.0.0.1:*");
assert (rc == 0);
rc = zmq_getsockopt (router, ZMQ_LAST_ENDPOINT, my_endpoint, &len);
assert (rc == 0);
void *router = test_context_socket (ZMQ_ROUTER);
bind_loopback_ipv4 (router, my_endpoint, sizeof my_endpoint);
void *dealer = zmq_socket (ctx, ZMQ_DEALER);
assert (dealer);
rc = zmq_connect (dealer, my_endpoint);
assert (rc == 0);
void *dealer = test_context_socket (ZMQ_DEALER);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (dealer, my_endpoint));
// Test that creating and closing a message triggers ffn
zmq_msg_t msg;
......@@ -67,80 +67,68 @@ int main (void)
memset (data, 0, 255);
memcpy (data, (void *) "data", 4);
memcpy (hint, (void *) "hint", 4);
rc = zmq_msg_init_data (&msg, (void *) data, 255, ffn, (void *) hint);
assert (rc == 0);
rc = zmq_msg_close (&msg);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_msg_init_data (&msg, (void *) data, 255, ffn, (void *) hint));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&msg));
msleep (SETTLE_TIME);
assert (memcmp (hint, "freed", 5) == 0);
TEST_ASSERT_EQUAL_STRING_LEN ("freed", hint, 5);
memcpy (hint, (void *) "hint", 4);
// Making and closing a copy triggers ffn
zmq_msg_t msg2;
zmq_msg_init (&msg2);
rc = zmq_msg_init_data (&msg, (void *) data, 255, ffn, (void *) hint);
assert (rc == 0);
rc = zmq_msg_copy (&msg2, &msg);
assert (rc == 0);
rc = zmq_msg_close (&msg2);
assert (rc == 0);
rc = zmq_msg_close (&msg);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_msg_init_data (&msg, (void *) data, 255, ffn, (void *) hint));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_copy (&msg2, &msg));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&msg2));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&msg));
msleep (SETTLE_TIME);
assert (memcmp (hint, "freed", 5) == 0);
TEST_ASSERT_EQUAL_STRING_LEN ("freed", hint, 5);
memcpy (hint, (void *) "hint", 4);
// Test that sending a message triggers ffn
rc = zmq_msg_init_data (&msg, (void *) data, 255, ffn, (void *) hint);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_msg_init_data (&msg, (void *) data, 255, ffn, (void *) hint));
zmq_msg_send (&msg, dealer, 0);
char buf[255];
rc = zmq_recv (router, buf, 255, 0);
assert (rc > -1);
rc = zmq_recv (router, buf, 255, 0);
assert (rc == 255);
assert (memcmp (data, buf, 4) == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_recv (router, buf, 255, 0));
TEST_ASSERT_EQUAL_INT (255, zmq_recv (router, buf, 255, 0));
TEST_ASSERT_EQUAL_STRING_LEN (data, buf, 4);
msleep (SETTLE_TIME);
assert (memcmp (hint, "freed", 5) == 0);
TEST_ASSERT_EQUAL_STRING_LEN ("freed", hint, 5);
memcpy (hint, (void *) "hint", 4);
rc = zmq_msg_close (&msg);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&msg));
// Sending a copy of a message triggers ffn
rc = zmq_msg_init (&msg2);
assert (rc == 0);
rc = zmq_msg_init_data (&msg, (void *) data, 255, ffn, (void *) hint);
assert (rc == 0);
rc = zmq_msg_copy (&msg2, &msg);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init (&msg2));
TEST_ASSERT_SUCCESS_ERRNO (
zmq_msg_init_data (&msg, (void *) data, 255, ffn, (void *) hint));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_copy (&msg2, &msg));
zmq_msg_send (&msg, dealer, 0);
rc = zmq_recv (router, buf, 255, 0);
assert (rc > -1);
rc = zmq_recv (router, buf, 255, 0);
assert (rc == 255);
assert (memcmp (data, buf, 4) == 0);
rc = zmq_msg_close (&msg2);
assert (rc == 0);
rc = zmq_msg_close (&msg);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_recv (router, buf, 255, 0));
TEST_ASSERT_EQUAL_INT (255, zmq_recv (router, buf, 255, 0));
TEST_ASSERT_EQUAL_STRING_LEN (data, buf, 4);
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&msg2));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&msg));
msleep (SETTLE_TIME);
assert (memcmp (hint, "freed", 5) == 0);
memcpy (hint, (void *) "hint", 4);
TEST_ASSERT_EQUAL_STRING_LEN ("freed", hint, 5);
// Deallocate the infrastructure.
rc = zmq_close (router);
assert (rc == 0);
test_context_socket_close (router);
test_context_socket_close (dealer);
}
rc = zmq_close (dealer);
assert (rc == 0);
int main (void)
{
setup_test_environment ();
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0;
UNITY_BEGIN ();
RUN_TEST (test_msg_ffn);
return UNITY_END ();
}
......@@ -28,99 +28,98 @@
*/
#include "testutil.hpp"
#include "testutil_unity.hpp"
int main (void)
void setUp ()
{
setup_test_environment ();
// Create the infrastructure
void *ctx = zmq_ctx_new ();
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_ROUTER);
assert (sb);
setup_test_context ();
}
int rc = zmq_bind (sb, "inproc://a");
assert (rc == 0);
void tearDown ()
{
teardown_test_context ();
}
void *sc = zmq_socket (ctx, ZMQ_DEALER);
assert (sc);
void test_more ()
{
// Create the infrastructure
void *sb = test_context_socket (ZMQ_ROUTER);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, "inproc://a"));
rc = zmq_connect (sc, "inproc://a");
assert (rc == 0);
void *sc = test_context_socket (ZMQ_DEALER);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, "inproc://a"));
// Send 2-part message.
rc = zmq_send (sc, "A", 1, ZMQ_SNDMORE);
assert (rc == 1);
rc = zmq_send (sc, "B", 1, 0);
assert (rc == 1);
send_string_expect_success (sc, "A", ZMQ_SNDMORE);
send_string_expect_success (sc, "B", 0);
// Routing id comes first.
zmq_msg_t msg;
rc = zmq_msg_init (&msg);
assert (rc == 0);
rc = zmq_msg_recv (&msg, sb, 0);
assert (rc >= 0);
int more = zmq_msg_more (&msg);
assert (more == 1);
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init (&msg));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, sb, 0));
TEST_ASSERT_EQUAL_INT (1, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_more (&msg)));
// Then the first part of the message body.
rc = zmq_msg_recv (&msg, sb, 0);
assert (rc == 1);
more = zmq_msg_more (&msg);
assert (more == 1);
TEST_ASSERT_EQUAL_INT (
1, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, sb, 0)));
TEST_ASSERT_EQUAL_INT (1, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_more (&msg)));
// And finally, the second part of the message body.
rc = zmq_msg_recv (&msg, sb, 0);
assert (rc == 1);
more = zmq_msg_more (&msg);
assert (more == 0);
TEST_ASSERT_EQUAL_INT (
1, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, sb, 0)));
TEST_ASSERT_EQUAL_INT (0, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_more (&msg)));
// Deallocate the infrastructure.
test_context_socket_close (sc);
test_context_socket_close (sb);
}
void test_shared_refcounted ()
{
// Test ZMQ_SHARED property (case 1, refcounted messages)
zmq_msg_t msg_a;
rc = zmq_msg_init_size (&msg_a, 1024); // large enough to be a type_lmsg
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_msg_init_size (&msg_a, 1024)); // large enough to be a type_lmsg
// Message is not shared
rc = zmq_msg_get (&msg_a, ZMQ_SHARED);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_get (&msg_a, ZMQ_SHARED));
zmq_msg_t msg_b;
rc = zmq_msg_init (&msg_b);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init (&msg_b));
rc = zmq_msg_copy (&msg_b, &msg_a);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_copy (&msg_b, &msg_a));
// Message is now shared
rc = zmq_msg_get (&msg_b, ZMQ_SHARED);
assert (rc == 1);
TEST_ASSERT_EQUAL_INT (
1, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_get (&msg_b, ZMQ_SHARED)));
// cleanup
rc = zmq_msg_close (&msg_a);
assert (rc == 0);
rc = zmq_msg_close (&msg_b);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&msg_a));
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&msg_b));
}
void test_shared_const ()
{
zmq_msg_t msg_a;
// Test ZMQ_SHARED property (case 2, constant data messages)
rc = zmq_msg_init_data (&msg_a, (void *) "TEST", 5, 0, 0);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_msg_init_data (&msg_a, (void *) "TEST", 5, 0, 0));
// Message reports as shared
rc = zmq_msg_get (&msg_a, ZMQ_SHARED);
assert (rc == 1);
TEST_ASSERT_EQUAL_INT (
1, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_get (&msg_a, ZMQ_SHARED)));
// cleanup
rc = zmq_msg_close (&msg_a);
assert (rc == 0);
// Deallocate the infrastructure.
rc = zmq_close (sc);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&msg_a));
}
rc = zmq_close (sb);
assert (rc == 0);
int main ()
{
setup_test_environment ();
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0;
UNITY_BEGIN ();
RUN_TEST (test_more);
RUN_TEST (test_shared_refcounted);
RUN_TEST (test_shared_const);
return UNITY_END ();
}
......@@ -30,6 +30,8 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
void setUp ()
{
setup_test_context ();
......
......@@ -45,9 +45,8 @@ typedef void (*extra_func_t) (void *socket_);
void set_sockopt_bind_to_device (void *socket)
{
const char device[] = "lo";
int rc =
zmq_setsockopt (socket, ZMQ_BINDTODEVICE, &device, sizeof (device) - 1);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_setsockopt (socket, ZMQ_BINDTODEVICE, &device, sizeof (device) - 1));
}
// TODO this is duplicated from test_pair_tcp
......
......@@ -32,37 +32,41 @@
#include <vmci_sockets.h>
#include "testutil.hpp"
#include "testutil_unity.hpp"
int main (void)
void setUp ()
{
setup_test_environment ();
void *ctx = zmq_ctx_new ();
assert (ctx);
setup_test_context ();
}
void tearDown ()
{
teardown_test_context ();
}
void test_pair_vmci ()
{
std::stringstream s;
s << "vmci://" << VMCISock_GetLocalCID () << ":" << 5560;
std::string endpoint = s.str ();
void *sb = zmq_socket (ctx, ZMQ_PAIR);
assert (sb);
int rc = zmq_bind (sb, endpoint.c_str ());
assert (rc == 0);
void *sb = test_context_socket (ZMQ_PAIR);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, endpoint.c_str ()));
void *sc = zmq_socket (ctx, ZMQ_PAIR);
assert (sc);
rc = zmq_connect (sc, endpoint.c_str ());
assert (rc == 0);
void *sc = test_context_socket (ZMQ_PAIR);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, endpoint.c_str ()));
bounce (sb, sc);
rc = zmq_close (sc);
assert (rc == 0);
rc = zmq_close (sb);
assert (rc == 0);
test_context_socket_close (sc);
test_context_socket_close (sb);
}
rc = zmq_ctx_term (ctx);
assert (rc == 0);
int main (void)
{
setup_test_environment ();
return 0;
UNITY_BEGIN ();
RUN_TEST (test_pair_vmci);
return UNITY_END ();
}
......@@ -33,6 +33,13 @@
#include <unity.h>
#include <limits.h>
#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#endif
void setUp ()
{
setup_test_context ();
......
This diff is collapsed.
......@@ -29,7 +29,10 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
#include <unity.h>
#include <assert.h>
#include <unistd.h>
//
// Asynchronous proxy test using ZMQ_XPUB_NODROP and HWM:
......
......@@ -28,92 +28,83 @@
*/
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
void setUp ()
{
setup_test_context ();
}
void tearDown ()
{
teardown_test_context ();
}
// This is our server task.
// It runs a proxy with a single REP socket as both frontend and backend.
void server_task (void *ctx_)
void server_task (void * /*unused_*/)
{
size_t len = MAX_SOCKET_STRING;
char my_endpoint[MAX_SOCKET_STRING];
void *rep = zmq_socket (ctx_, ZMQ_REP);
assert (rep);
int rc = zmq_bind (rep, "tcp://127.0.0.1:*");
assert (rc == 0);
rc = zmq_getsockopt (rep, ZMQ_LAST_ENDPOINT, my_endpoint, &len);
assert (rc == 0);
void *rep = zmq_socket (get_test_context (), ZMQ_REP);
TEST_ASSERT_NOT_NULL (rep);
bind_loopback_ipv4 (rep, my_endpoint, sizeof my_endpoint);
// Control socket receives terminate command from main over inproc
void *control = zmq_socket (ctx_, ZMQ_REQ);
assert (control);
rc = zmq_connect (control, "inproc://control");
assert (rc == 0);
rc = s_send (control, my_endpoint);
assert (rc > 0);
void *control = zmq_socket (get_test_context (), ZMQ_REQ);
TEST_ASSERT_NOT_NULL (control);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (control, "inproc://control"));
TEST_ASSERT_GREATER_THAN_INT (
0, TEST_ASSERT_SUCCESS_ERRNO (s_send (control, my_endpoint)));
// Use rep as both frontend and backend
rc = zmq_proxy_steerable (rep, rep, NULL, control);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_proxy_steerable (rep, rep, NULL, control));
rc = zmq_close (rep);
assert (rc == 0);
rc = zmq_close (control);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_close (rep));
TEST_ASSERT_SUCCESS_ERRNO (zmq_close (control));
}
// The main thread simply starts several clients and a server, and then
// waits for the server to finish.
int main (void)
void test_proxy_single_socket ()
{
setup_test_environment ();
void *ctx = zmq_ctx_new ();
assert (ctx);
void *server_thread = zmq_threadstart (&server_task, ctx);
void *server_thread = zmq_threadstart (&server_task, NULL);
// Control socket receives terminate command from main over inproc
void *control = zmq_socket (ctx, ZMQ_REP);
assert (control);
int rc = zmq_bind (control, "inproc://control");
assert (rc == 0);
void *control = test_context_socket (ZMQ_REP);
TEST_ASSERT_NOT_NULL (control);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (control, "inproc://control"));
char *my_endpoint = s_recv (control);
assert (my_endpoint);
TEST_ASSERT_NOT_NULL (my_endpoint);
// client socket pings proxy over tcp
void *req = zmq_socket (ctx, ZMQ_REQ);
assert (req);
rc = zmq_connect (req, my_endpoint);
assert (rc == 0);
char buf[255];
rc = zmq_send (req, "msg1", 4, 0);
assert (rc == 4);
rc = zmq_recv (req, buf, 255, 0);
assert (rc == 4);
assert (memcmp (buf, "msg1", 4) == 0);
rc = zmq_send (req, "msg22", 5, 0);
assert (rc == 5);
rc = zmq_recv (req, buf, 255, 0);
assert (rc == 5);
assert (memcmp (buf, "msg22", 5) == 0);
rc = zmq_send (control, "TERMINATE", 9, 0);
assert (rc == 9);
rc = zmq_close (control);
assert (rc == 0);
rc = zmq_close (req);
assert (rc == 0);
void *req = test_context_socket (ZMQ_REQ);
TEST_ASSERT_NOT_NULL (req);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (req, my_endpoint));
send_string_expect_success (req, "msg1", 0);
recv_string_expect_success (req, "msg1", 0);
send_string_expect_success (req, "msg22", 0);
recv_string_expect_success (req, "msg22", 0);
send_string_expect_success (control, "TERMINATE", 0);
test_context_socket_close (control);
test_context_socket_close (req);
free (my_endpoint);
zmq_threadclose (server_thread);
}
int main (void)
{
setup_test_environment ();
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0;
UNITY_BEGIN ();
RUN_TEST (test_proxy_single_socket);
return UNITY_END ();
}
......@@ -28,104 +28,98 @@
*/
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
void setUp ()
{
setup_test_context ();
}
void tearDown ()
{
teardown_test_context ();
}
// This is a test for issue #1382. The server thread creates a SUB-PUSH
// steerable proxy. The main process then sends messages to the SUB
// but there is no pull on the other side, previously the proxy blocks
// in writing to the backend, preventing the proxy from terminating
void server_task (void *ctx_)
void server_task (void * /*unused_*/)
{
size_t len = MAX_SOCKET_STRING;
char my_endpoint[MAX_SOCKET_STRING];
// Frontend socket talks to main process
void *frontend = zmq_socket (ctx_, ZMQ_SUB);
assert (frontend);
int rc = zmq_setsockopt (frontend, ZMQ_SUBSCRIBE, "", 0);
assert (rc == 0);
rc = zmq_bind (frontend, "tcp://127.0.0.1:*");
assert (rc == 0);
rc = zmq_getsockopt (frontend, ZMQ_LAST_ENDPOINT, my_endpoint, &len);
assert (rc == 0);
void *frontend = zmq_socket (get_test_context (), ZMQ_SUB);
TEST_ASSERT_NOT_NULL (frontend);
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (frontend, ZMQ_SUBSCRIBE, "", 0));
bind_loopback_ipv4 (frontend, my_endpoint, sizeof my_endpoint);
// Nice socket which is never read
void *backend = zmq_socket (ctx_, ZMQ_PUSH);
assert (backend);
rc = zmq_bind (backend, "tcp://127.0.0.1:*");
assert (rc == 0);
void *backend = zmq_socket (get_test_context (), ZMQ_PUSH);
TEST_ASSERT_NOT_NULL (backend);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (backend, "tcp://127.0.0.1:*"));
// Control socket receives terminate command from main over inproc
void *control = zmq_socket (ctx_, ZMQ_REQ);
assert (control);
rc = zmq_connect (control, "inproc://control");
assert (rc == 0);
rc = s_send (control, my_endpoint);
assert (rc > 0);
void *control = zmq_socket (get_test_context (), ZMQ_REQ);
TEST_ASSERT_NOT_NULL (control);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (control, "inproc://control"));
TEST_ASSERT_GREATER_THAN_INT (
0, TEST_ASSERT_SUCCESS_ERRNO (s_send (control, my_endpoint)));
// Connect backend to frontend via a proxy
rc = zmq_proxy_steerable (frontend, backend, NULL, control);
assert (rc == 0);
rc = zmq_close (frontend);
assert (rc == 0);
rc = zmq_close (backend);
assert (rc == 0);
rc = zmq_close (control);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (
zmq_proxy_steerable (frontend, backend, NULL, control));
TEST_ASSERT_SUCCESS_ERRNO (zmq_close (frontend));
TEST_ASSERT_SUCCESS_ERRNO (zmq_close (backend));
TEST_ASSERT_SUCCESS_ERRNO (zmq_close (control));
}
// The main thread simply starts a basic steerable proxy server, publishes some messages, and then
// waits for the server to terminate.
int main (void)
void test_proxy_terminate ()
{
setup_test_environment ();
void *ctx = zmq_ctx_new ();
assert (ctx);
void *thread = zmq_threadstart (&server_task, ctx);
void *thread = zmq_threadstart (&server_task, NULL);
// Control socket receives terminate command from main over inproc
void *control = zmq_socket (ctx, ZMQ_REP);
assert (control);
int rc = zmq_bind (control, "inproc://control");
assert (rc == 0);
void *control = test_context_socket (ZMQ_REP);
TEST_ASSERT_NOT_NULL (control);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (control, "inproc://control"));
char *my_endpoint = s_recv (control);
assert (my_endpoint);
TEST_ASSERT_NOT_NULL (my_endpoint);
msleep (500); // Run for 500 ms
// Start a secondary publisher which writes data to the SUB-PUSH server socket
void *publisher = zmq_socket (ctx, ZMQ_PUB);
assert (publisher);
rc = zmq_connect (publisher, my_endpoint);
assert (rc == 0);
void *publisher = test_context_socket (ZMQ_PUB);
TEST_ASSERT_NOT_NULL (publisher);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (publisher, my_endpoint));
msleep (SETTLE_TIME);
rc = zmq_send (publisher, "This is a test", 14, 0);
assert (rc == 14);
send_string_expect_success (publisher, "This is a test", 0);
msleep (50);
rc = zmq_send (publisher, "This is a test", 14, 0);
assert (rc == 14);
send_string_expect_success (publisher, "This is a test", 0);
msleep (50);
rc = zmq_send (publisher, "This is a test", 14, 0);
assert (rc == 14);
rc = zmq_send (control, "TERMINATE", 9, 0);
assert (rc == 9);
rc = zmq_close (publisher);
assert (rc == 0);
rc = zmq_close (control);
assert (rc == 0);
send_string_expect_success (publisher, "This is a test", 0);
send_string_expect_success (control, "TERMINATE", 0);
test_context_socket_close (publisher);
test_context_socket_close (control);
free (my_endpoint);
zmq_threadclose (thread);
}
int main (void)
{
setup_test_environment ();
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0;
UNITY_BEGIN ();
RUN_TEST (test_proxy_terminate);
return UNITY_END ();
}
......@@ -30,6 +30,8 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
void setUp ()
{
setup_test_context ();
......
......@@ -32,6 +32,15 @@
#include <unity.h>
#include <string.h>
#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#endif
// Helper macro to define the v4/v6 function pairs
#define MAKE_TEST_V4V6(_test) \
static void _test##_ipv4 () { _test (false); } \
......
......@@ -79,7 +79,7 @@ void test_req_correlate ()
// Receive request id 1
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, router, 0));
assert (zmq_msg_size (&msg) == sizeof (uint32_t));
TEST_ASSERT_EQUAL_UINT (sizeof (uint32_t), zmq_msg_size (&msg));
const uint32_t req_id = *static_cast<uint32_t *> (zmq_msg_data (&msg));
zmq_msg_t req_id_msg;
zmq_msg_init (&req_id_msg);
......
......@@ -30,6 +30,7 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <unity.h>
void setUp ()
......
......@@ -30,6 +30,8 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
void setUp ()
{
setup_test_context ();
......
......@@ -32,37 +32,41 @@
#include <vmci_sockets.h>
#include "testutil.hpp"
#include "testutil_unity.hpp"
int main (void)
void setUp ()
{
setup_test_environment ();
void *ctx = zmq_ctx_new ();
assert (ctx);
setup_test_context ();
}
void tearDown ()
{
teardown_test_context ();
}
void test_reqrep_vmci ()
{
std::stringstream s;
s << "vmci://" << VMCISock_GetLocalCID () << ":" << 5560;
std::string endpoint = s.str ();
void *sb = zmq_socket (ctx, ZMQ_REP);
assert (sb);
int rc = zmq_bind (sb, endpoint.c_str ());
assert (rc == 0);
void *sb = test_context_socket (ZMQ_REP);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, endpoint.c_str ()));
void *sc = zmq_socket (ctx, ZMQ_REQ);
assert (sc);
rc = zmq_connect (sc, endpoint.c_str ());
assert (rc == 0);
void *sc = test_context_socket (ZMQ_REQ);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, endpoint.c_str ()));
bounce (sb, sc);
rc = zmq_close (sc);
assert (rc == 0);
rc = zmq_close (sb);
assert (rc == 0);
test_context_socket_close (sc);
test_context_socket_close (sb);
}
rc = zmq_ctx_term (ctx);
assert (rc == 0);
int main (void)
{
setup_test_environment ();
return 0;
UNITY_BEGIN ();
RUN_TEST (test_reqrep_vmci);
return UNITY_END ();
}
......@@ -30,6 +30,7 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
#include <unity.h>
void setUp ()
......
......@@ -30,47 +30,49 @@
#include <stdio.h>
#include "testutil.hpp"
int main (void)
#include "testutil_unity.hpp"
void setUp ()
{
if (!is_tipc_available ()) {
printf ("TIPC environment unavailable, skipping test\n");
return 77;
}
setup_test_context ();
}
fprintf (stderr, "test_router_mandatory_tipc running...\n");
void tearDown ()
{
teardown_test_context ();
}
void *ctx = zmq_init (1);
assert (ctx);
void test_router_mandatory_tipc ()
{
if (!is_tipc_available ()) {
TEST_IGNORE_MESSAGE ("TIPC environment unavailable, skipping test");
}
// Creating the first socket.
void *sa = zmq_socket (ctx, ZMQ_ROUTER);
assert (sa);
void *sa = test_context_socket (ZMQ_ROUTER);
int rc = zmq_bind (sa, "tipc://{15560,0,0}");
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sa, "tipc://{15560,0,0}"));
// Sending a message to an unknown peer with the default setting
rc = zmq_send (sa, "UNKNOWN", 7, ZMQ_SNDMORE);
assert (rc == 7);
rc = zmq_send (sa, "DATA", 4, 0);
assert (rc == 4);
send_string_expect_success (sa, "UNKNOWN", ZMQ_SNDMORE);
send_string_expect_success (sa, "DATA", 0);
int mandatory = 1;
// Set mandatory routing on socket
rc =
zmq_setsockopt (sa, ZMQ_ROUTER_MANDATORY, &mandatory, sizeof (mandatory));
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (sa, ZMQ_ROUTER_MANDATORY,
&mandatory, sizeof (mandatory)));
// Send a message and check that it fails
rc = zmq_send (sa, "UNKNOWN", 7, ZMQ_SNDMORE | ZMQ_DONTWAIT);
assert (rc == -1 && errno == EHOSTUNREACH);
rc = zmq_close (sa);
assert (rc == 0);
TEST_ASSERT_FAILURE_ERRNO (
EHOSTUNREACH, zmq_send (sa, "UNKNOWN", 7, ZMQ_SNDMORE | ZMQ_DONTWAIT));
rc = zmq_ctx_term (ctx);
assert (rc == 0);
test_context_socket_close (sa);
}
return 0;
int main (void)
{
UNITY_BEGIN ();
RUN_TEST (test_router_mandatory_tipc);
return UNITY_END ();
}
......@@ -30,6 +30,7 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
#include <unity.h>
void setUp ()
......
This diff is collapsed.
......@@ -42,6 +42,8 @@
#include <unistd.h>
#endif
#include <stdlib.h>
static void zap_handler (void *handler_)
{
// Process ZAP requests forever
......@@ -56,8 +58,8 @@ static void zap_handler (void *handler_)
char *routing_id = s_recv (handler_);
char *mechanism = s_recv (handler_);
assert (streq (version, "1.0"));
assert (streq (mechanism, "NULL"));
TEST_ASSERT_EQUAL_STRING ("1.0", version);
TEST_ASSERT_EQUAL_STRING ("NULL", mechanism);
s_sendmore (handler_, version);
s_sendmore (handler_, sequence);
......
......@@ -42,6 +42,9 @@
#include <unistd.h>
#endif
#include <stdlib.h>
#include <string.h>
static void zap_handler (void *zap_)
{
// Process ZAP requests forever
......@@ -57,9 +60,9 @@ static void zap_handler (void *zap_)
char *username = s_recv (zap_);
char *password = s_recv (zap_);
assert (streq (version, "1.0"));
assert (streq (mechanism, "PLAIN"));
assert (streq (routing_id, "IDENT"));
TEST_ASSERT_EQUAL_STRING ("1.0", version);
TEST_ASSERT_EQUAL_STRING ("PLAIN", mechanism);
TEST_ASSERT_EQUAL_STRING ("IDENT", routing_id);
s_sendmore (zap_, version);
s_sendmore (zap_, sequence);
......@@ -83,8 +86,7 @@ static void zap_handler (void *zap_)
free (username);
free (password);
}
int rc = zmq_close (zap_);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_close (zap_));
}
void *zap_thread;
......
......@@ -30,6 +30,8 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
void setUp ()
{
setup_test_context ();
......
......@@ -30,6 +30,8 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <pthread.h>
void setUp ()
{
}
......
......@@ -30,6 +30,9 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <string.h>
void setUp ()
{
setup_test_context ();
......
......@@ -30,6 +30,7 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <unity.h>
void setUp ()
......
......@@ -30,6 +30,8 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <string.h>
#include <unity.h>
void setUp ()
......
......@@ -30,6 +30,7 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
#include <unity.h>
void setUp ()
......
......@@ -30,6 +30,8 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
void setUp ()
{
setup_test_context ();
......
......@@ -30,6 +30,8 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
void setUp ()
{
setup_test_context ();
......
......@@ -30,6 +30,14 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
#ifndef _WIN32
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#endif
void setUp ()
{
setup_test_context ();
......
......@@ -30,6 +30,9 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <string.h>
void setUp ()
{
setup_test_context ();
......
......@@ -28,6 +28,7 @@
*/
#include "testutil.hpp"
#include "testutil_unity.hpp"
#if defined(ZMQ_HAVE_WINDOWS)
#include <winsock2.h>
......@@ -38,6 +39,16 @@
#include <unistd.h>
#endif
void setUp ()
{
setup_test_context ();
}
void tearDown ()
{
teardown_test_context ();
}
// Solaris has a default of 256 max files per process
#ifdef ZMQ_HAVE_SOLARIS
#define MAX_SOCKETS 200
......@@ -62,25 +73,21 @@ void initialise_network (void)
#endif
// This test case stresses the system to shake out known configuration
// problems. We're direct system calls when necessary. Some code may
// need wrapping to be properly portable.
int main (void)
void test_localhost ()
{
initialise_network ();
// Check that we have local networking via ZeroMQ
void *ctx = zmq_ctx_new ();
assert (ctx);
void *dealer = zmq_socket (ctx, ZMQ_DEALER);
void *dealer = test_context_socket (ZMQ_DEALER);
if (zmq_bind (dealer, "tcp://127.0.0.1:*") == -1) {
printf (
"E: Cannot find 127.0.0.1 -- your system does not have local\n");
printf (
TEST_FAIL_MESSAGE (
"E: Cannot find 127.0.0.1 -- your system does not have local\n"
"E: networking. Please fix this before running libzmq checks.\n");
return -1;
}
test_context_socket_close (dealer);
}
void test_max_sockets ()
{
// Check that we can create 1,000 sockets
fd_t handle[MAX_SOCKETS];
int count;
......@@ -88,19 +95,31 @@ int main (void)
handle[count] = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (handle[count] == -1) {
printf ("W: Only able to create %d sockets on this box\n", count);
printf (
"I: Tune your system to increase maximum allowed file handles\n");
const char msg[] =
"I: Tune your system to increase maximum allowed file handles\n"
#if !defined(ZMQ_HAVE_WINDOWS)
printf ("I: Run 'ulimit -n 1200' in bash\n");
"I: Run 'ulimit -n 1200' in bash\n"
#endif
return -1;
;
TEST_FAIL_MESSAGE (msg);
}
}
// Release the socket handles
for (count = 0; count < MAX_SOCKETS; count++) {
close (handle[count]);
}
}
// This test case stresses the system to shake out known configuration
// problems. We're direct system calls when necessary. Some code may
// need wrapping to be properly portable.
int main (void)
{
initialise_network ();
zmq_close (dealer);
zmq_ctx_term (ctx);
UNITY_BEGIN ();
RUN_TEST (test_localhost);
RUN_TEST (test_max_sockets);
return UNITY_END ();
}
......@@ -28,98 +28,84 @@
*/
#include "testutil.hpp"
#include "testutil_unity.hpp"
int main (void)
void setUp ()
{
if (!is_tipc_available ()) {
printf ("TIPC environment unavailable, skipping test\n");
return 77;
}
setup_test_context ();
}
void tearDown ()
{
teardown_test_context ();
}
int rc;
char buf[32];
const char *ep = "tipc://{5560,0,0}";
const char *name = "tipc://{5560,0}@0.0.0";
const char ep[] = "tipc://{5560,0,0}";
const char name[] = "tipc://{5560,0}@0.0.0";
fprintf (stderr, "unbind endpoint test running...\n");
void test_term_endpoint_unbind_tipc ()
{
if (!is_tipc_available ()) {
TEST_IGNORE_MESSAGE ("TIPC environment unavailable, skipping test\n");
}
// Create infrastructure.
void *ctx = zmq_init (1);
assert (ctx);
void *push = zmq_socket (ctx, ZMQ_PUSH);
assert (push);
rc = zmq_bind (push, ep);
assert (rc == 0);
void *pull = zmq_socket (ctx, ZMQ_PULL);
assert (pull);
rc = zmq_connect (pull, name);
assert (rc == 0);
void *push = test_context_socket (ZMQ_PUSH);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (push, ep));
void *pull = test_context_socket (ZMQ_PULL);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (pull, name));
// Pass one message through to ensure the connection is established.
rc = zmq_send (push, "ABC", 3, 0);
assert (rc == 3);
rc = zmq_recv (pull, buf, sizeof (buf), 0);
assert (rc == 3);
send_string_expect_success (push, "ABC", 0);
recv_string_expect_success (pull, "ABC", 0);
// Unbind the lisnening endpoint
rc = zmq_unbind (push, ep);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_unbind (push, ep));
// Let events some time
msleep (SETTLE_TIME);
// Check that sending would block (there's no outbound connection).
rc = zmq_send (push, "ABC", 3, ZMQ_DONTWAIT);
assert (rc == -1 && zmq_errno () == EAGAIN);
TEST_ASSERT_FAILURE_ERRNO (EAGAIN, zmq_send (push, "ABC", 3, ZMQ_DONTWAIT));
// Clean up.
rc = zmq_close (pull);
assert (rc == 0);
rc = zmq_close (push);
assert (rc == 0);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
// Now the other way round.
fprintf (stderr, "disconnect endpoint test running...\n");
test_context_socket_close (pull);
test_context_socket_close (push);
}
void test_term_endpoint_disconnect_tipc ()
{
if (!is_tipc_available ()) {
TEST_IGNORE_MESSAGE ("TIPC environment unavailable, skipping test\n");
}
// Create infrastructure.
ctx = zmq_init (1);
assert (ctx);
push = zmq_socket (ctx, ZMQ_PUSH);
assert (push);
rc = zmq_connect (push, name);
assert (rc == 0);
pull = zmq_socket (ctx, ZMQ_PULL);
assert (pull);
rc = zmq_bind (pull, ep);
assert (rc == 0);
void *push = test_context_socket (ZMQ_PUSH);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (push, name));
void *pull = test_context_socket (ZMQ_PULL);
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (pull, ep));
// Pass one message through to ensure the connection is established.
rc = zmq_send (push, "ABC", 3, 0);
assert (rc == 3);
rc = zmq_recv (pull, buf, sizeof (buf), 0);
assert (rc == 3);
send_string_expect_success (push, "ABC", 0);
recv_string_expect_success (pull, "ABC", 0);
// Disconnect the bound endpoint
rc = zmq_disconnect (push, name);
assert (rc == 0);
TEST_ASSERT_SUCCESS_ERRNO (zmq_disconnect (push, name));
msleep (SETTLE_TIME);
// Check that sending would block (there's no inbound connections).
rc = zmq_send (push, "ABC", 3, ZMQ_DONTWAIT);
assert (rc == -1 && zmq_errno () == EAGAIN);
TEST_ASSERT_FAILURE_ERRNO (EAGAIN, zmq_send (push, "ABC", 3, ZMQ_DONTWAIT));
// Clean up.
rc = zmq_close (pull);
assert (rc == 0);
rc = zmq_close (push);
assert (rc == 0);
rc = zmq_ctx_term (ctx);
assert (rc == 0);
return 0;
test_context_socket_close (pull);
test_context_socket_close (push);
}
int main (void)
{
UNITY_BEGIN ();
RUN_TEST (test_term_endpoint_unbind_tipc);
RUN_TEST (test_term_endpoint_disconnect_tipc);
return UNITY_END ();
}
......@@ -20,6 +20,8 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <string.h>
void setUp ()
{
setup_test_context ();
......
......@@ -30,7 +30,10 @@
#include "testutil.hpp"
#include "testutil_unity.hpp"
#include <stdlib.h>
#include <string.h>
#include <unity.h>
#include <unistd.h>
void setUp ()
{
......@@ -47,6 +50,7 @@ void tearDown ()
#include <sys/socket.h>
#include <sys/un.h>
#include <netdb.h>
#include <unistd.h>
int setup_socket_and_set_fd (void *zmq_socket_,
int af_,
......
......@@ -31,8 +31,13 @@
#include "testutil_unity.hpp"
#include <netdb.h>
#include <string.h>
#include <unity.h>
#ifndef _WIN32
#include <unistd.h>
#endif
void setUp ()
{
setup_test_context ();
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -35,7 +35,7 @@ foreach(test ${unittests})
link_directories(${test} PRIVATE "${ZeroMQ_SOURCE_DIR}/../lib")
endif()
target_link_libraries(${test} libzmq-static ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} unity)
target_link_libraries(${test} testutil-static)
if(RT_LIBRARY)
target_link_libraries(${test} ${RT_LIBRARY})
......
This diff is collapsed.
This diff is collapsed.
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