2013-09-12 14:44:44 +01:00
|
|
|
/*
|
2016-01-28 15:07:31 +01:00
|
|
|
Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file
|
2013-09-12 14:44:44 +01:00
|
|
|
|
2015-06-02 22:33:55 +02:00
|
|
|
This file is part of libzmq, the ZeroMQ core engine in C++.
|
2013-09-12 14:44:44 +01: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-09-12 14:44:44 +01: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-09-12 14:44:44 +01: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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "testutil.hpp"
|
2018-05-23 13:48:58 +02:00
|
|
|
#include "testutil_unity.hpp"
|
2013-09-12 14:44:44 +01:00
|
|
|
|
2019-03-24 12:51:28 -04:00
|
|
|
SETUP_TEARDOWN_TESTCONTEXT
|
2018-05-23 13:48:58 +02:00
|
|
|
|
|
|
|
static void pusher (void * /*unused*/)
|
2013-09-12 18:09:37 +01:00
|
|
|
{
|
|
|
|
// Connect first
|
2018-05-23 17:32:27 +02:00
|
|
|
// do not use test_context_socket here, as it is not thread-safe
|
2018-05-27 07:01:36 -04:00
|
|
|
void *connect_socket = zmq_socket (get_test_context (), ZMQ_PAIR);
|
2018-05-23 13:48:58 +02:00
|
|
|
|
2018-05-27 07:01:36 -04:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connect_socket, "inproc://sink"));
|
2013-09-12 18:09:37 +01:00
|
|
|
|
|
|
|
// Queue up some data
|
2018-05-27 07:01:36 -04:00
|
|
|
send_string_expect_success (connect_socket, "foobar", 0);
|
2013-09-12 18:09:37 +01:00
|
|
|
|
|
|
|
// Cleanup
|
2018-05-27 07:01:36 -04:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_close (connect_socket));
|
2013-09-12 18:09:37 +01:00
|
|
|
}
|
|
|
|
|
2018-05-23 13:48:58 +02:00
|
|
|
static void simult_conn (void *endpt_)
|
2014-05-09 11:46:17 -07:00
|
|
|
{
|
2018-05-23 13:48:58 +02:00
|
|
|
// Pull out arguments - endpoint string
|
|
|
|
const char *endpt = static_cast<const char *> (endpt_);
|
2014-05-09 11:46:17 -07:00
|
|
|
|
|
|
|
// Connect
|
2018-05-23 17:32:27 +02:00
|
|
|
// do not use test_context_socket here, as it is not thread-safe
|
2021-06-13 17:45:57 +01:00
|
|
|
void *connect_socket = zmq_socket (get_test_context (), ZMQ_PAIR);
|
2018-05-27 07:01:36 -04:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connect_socket, endpt));
|
2021-06-13 17:45:57 +01:00
|
|
|
recv_string_expect_success (connect_socket, "foobar", 0);
|
2014-05-09 11:46:17 -07:00
|
|
|
|
|
|
|
// Cleanup
|
2018-05-27 07:01:36 -04:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_close (connect_socket));
|
2014-05-09 11:46:17 -07:00
|
|
|
}
|
|
|
|
|
2018-05-23 13:48:58 +02:00
|
|
|
static void simult_bind (void *endpt_)
|
2014-05-09 11:46:17 -07:00
|
|
|
{
|
|
|
|
// Pull out arguments - context followed by endpoint string
|
2018-05-23 13:48:58 +02:00
|
|
|
const char *endpt = static_cast<const char *> (endpt_);
|
2014-05-09 11:46:17 -07:00
|
|
|
|
|
|
|
// Bind
|
2018-05-23 17:32:27 +02:00
|
|
|
// do not use test_context_socket here, as it is not thread-safe
|
2021-06-13 17:45:57 +01:00
|
|
|
void *bind_socket = zmq_socket (get_test_context (), ZMQ_PAIR);
|
2018-05-27 07:01:36 -04:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (bind_socket, endpt));
|
2021-06-13 17:45:57 +01:00
|
|
|
send_string_expect_success (bind_socket, "foobar", 0);
|
2014-05-09 11:46:17 -07:00
|
|
|
|
|
|
|
// Cleanup
|
2018-05-27 07:01:36 -04:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_close (bind_socket));
|
2014-05-09 11:46:17 -07:00
|
|
|
}
|
|
|
|
|
2014-02-12 23:10:23 +00:00
|
|
|
void test_bind_before_connect ()
|
2013-09-12 14:44:44 +01:00
|
|
|
{
|
|
|
|
// Bind first
|
2018-05-27 07:01:36 -04:00
|
|
|
void *bind_socket = test_context_socket (ZMQ_PAIR);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (bind_socket, "inproc://bbc"));
|
2013-09-12 14:44:44 +01:00
|
|
|
|
|
|
|
// Now connect
|
2018-05-27 07:01:36 -04:00
|
|
|
void *connect_socket = test_context_socket (ZMQ_PAIR);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connect_socket, "inproc://bbc"));
|
2014-02-12 23:10:23 +00:00
|
|
|
|
2013-09-12 14:44:44 +01:00
|
|
|
// Queue up some data
|
2018-05-27 07:01:36 -04:00
|
|
|
send_string_expect_success (connect_socket, "foobar", 0);
|
2013-09-12 14:44:44 +01:00
|
|
|
|
|
|
|
// Read pending message
|
2018-05-27 07:01:36 -04:00
|
|
|
recv_string_expect_success (bind_socket, "foobar", 0);
|
2013-09-12 14:44:44 +01:00
|
|
|
|
|
|
|
// Cleanup
|
2018-05-27 07:01:36 -04:00
|
|
|
test_context_socket_close (connect_socket);
|
|
|
|
test_context_socket_close (bind_socket);
|
2013-09-12 14:44:44 +01:00
|
|
|
}
|
|
|
|
|
2014-02-12 23:10:23 +00:00
|
|
|
void test_connect_before_bind ()
|
2013-09-12 14:44:44 +01:00
|
|
|
{
|
|
|
|
// Connect first
|
2018-05-27 07:01:36 -04:00
|
|
|
void *connect_socket = test_context_socket (ZMQ_PAIR);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connect_socket, "inproc://cbb"));
|
2013-09-12 14:44:44 +01:00
|
|
|
|
|
|
|
// Queue up some data
|
2018-05-27 07:01:36 -04:00
|
|
|
send_string_expect_success (connect_socket, "foobar", 0);
|
2013-09-12 14:44:44 +01:00
|
|
|
|
|
|
|
// Now bind
|
2018-05-27 07:01:36 -04:00
|
|
|
void *bind_socket = test_context_socket (ZMQ_PAIR);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (bind_socket, "inproc://cbb"));
|
2014-02-12 23:10:23 +00:00
|
|
|
|
2013-09-12 14:44:44 +01:00
|
|
|
// Read pending message
|
2018-05-27 07:01:36 -04:00
|
|
|
recv_string_expect_success (bind_socket, "foobar", 0);
|
2013-09-12 14:44:44 +01:00
|
|
|
|
|
|
|
// Cleanup
|
2018-05-27 07:01:36 -04:00
|
|
|
test_context_socket_close (connect_socket);
|
|
|
|
test_context_socket_close (bind_socket);
|
2013-09-12 14:44:44 +01:00
|
|
|
}
|
|
|
|
|
2014-02-12 23:10:23 +00:00
|
|
|
void test_connect_before_bind_pub_sub ()
|
2013-09-12 18:09:37 +01:00
|
|
|
{
|
|
|
|
// Connect first
|
2018-05-27 07:01:36 -04:00
|
|
|
void *connect_socket = test_context_socket (ZMQ_PUB);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connect_socket, "inproc://cbbps"));
|
2013-09-12 18:09:37 +01:00
|
|
|
|
|
|
|
// Queue up some data, this will be dropped
|
2018-05-27 07:01:36 -04:00
|
|
|
send_string_expect_success (connect_socket, "before", 0);
|
2013-09-12 18:09:37 +01:00
|
|
|
|
|
|
|
// Now bind
|
2018-05-27 07:01:36 -04:00
|
|
|
void *bind_socket = test_context_socket (ZMQ_SUB);
|
2018-05-23 13:48:58 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (
|
2018-05-27 07:01:36 -04:00
|
|
|
zmq_setsockopt (bind_socket, ZMQ_SUBSCRIBE, "", 0));
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (bind_socket, "inproc://cbbps"));
|
2014-02-12 23:10:23 +00:00
|
|
|
|
2013-09-12 18:09:37 +01:00
|
|
|
// Wait for pub-sub connection to happen
|
2013-11-06 13:30:41 +01:00
|
|
|
msleep (SETTLE_TIME);
|
2013-09-12 18:09:37 +01:00
|
|
|
|
|
|
|
// Queue up some data, this not will be dropped
|
2018-05-27 07:01:36 -04:00
|
|
|
send_string_expect_success (connect_socket, "after", 0);
|
2013-09-12 18:09:37 +01:00
|
|
|
|
|
|
|
// Read pending message
|
2018-05-27 07:01:36 -04:00
|
|
|
recv_string_expect_success (bind_socket, "after", 0);
|
2013-09-12 18:09:37 +01:00
|
|
|
|
|
|
|
// Cleanup
|
2018-05-27 07:01:36 -04:00
|
|
|
test_context_socket_close (connect_socket);
|
|
|
|
test_context_socket_close (bind_socket);
|
2013-09-12 18:09:37 +01:00
|
|
|
}
|
|
|
|
|
2016-09-24 18:07:23 +01:00
|
|
|
void test_connect_before_bind_ctx_term ()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 20; ++i) {
|
|
|
|
// Connect first
|
2018-05-27 07:01:36 -04:00
|
|
|
void *connect_socket = test_context_socket (ZMQ_ROUTER);
|
2016-09-24 18:07:23 +01:00
|
|
|
|
2019-01-14 23:49:28 +00:00
|
|
|
char ep[32];
|
2016-09-24 18:07:23 +01:00
|
|
|
sprintf (ep, "inproc://cbbrr%d", i);
|
2018-05-27 07:01:36 -04:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connect_socket, ep));
|
2016-09-24 18:07:23 +01:00
|
|
|
|
|
|
|
// Cleanup
|
2018-05-27 07:01:36 -04:00
|
|
|
test_context_socket_close (connect_socket);
|
2016-09-24 18:07:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-12 23:10:23 +00:00
|
|
|
void test_multiple_connects ()
|
2013-09-12 18:09:37 +01:00
|
|
|
{
|
|
|
|
const unsigned int no_of_connects = 10;
|
|
|
|
|
2018-05-27 07:01:36 -04:00
|
|
|
void *connect_socket[no_of_connects];
|
2013-09-12 18:09:37 +01:00
|
|
|
|
|
|
|
// Connect first
|
|
|
|
for (unsigned int i = 0; i < no_of_connects; ++i) {
|
2018-05-27 07:01:36 -04:00
|
|
|
connect_socket[i] = test_context_socket (ZMQ_PUSH);
|
2018-05-23 13:48:58 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (
|
2018-05-27 07:01:36 -04:00
|
|
|
zmq_connect (connect_socket[i], "inproc://multiple"));
|
2013-09-12 18:09:37 +01:00
|
|
|
|
|
|
|
// Queue up some data
|
2018-05-27 07:01:36 -04:00
|
|
|
send_string_expect_success (connect_socket[i], "foobar", 0);
|
2013-09-12 18:09:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now bind
|
2018-05-27 07:01:36 -04:00
|
|
|
void *bind_socket = test_context_socket (ZMQ_PULL);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (bind_socket, "inproc://multiple"));
|
2014-02-12 23:10:23 +00:00
|
|
|
|
2013-09-12 18:09:37 +01:00
|
|
|
for (unsigned int i = 0; i < no_of_connects; ++i) {
|
2018-05-27 07:01:36 -04:00
|
|
|
recv_string_expect_success (bind_socket, "foobar", 0);
|
2013-09-12 18:09:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Cleanup
|
|
|
|
for (unsigned int i = 0; i < no_of_connects; ++i) {
|
2018-05-27 07:01:36 -04:00
|
|
|
test_context_socket_close (connect_socket[i]);
|
2013-09-12 18:09:37 +01:00
|
|
|
}
|
|
|
|
|
2018-05-27 07:01:36 -04:00
|
|
|
test_context_socket_close (bind_socket);
|
2013-09-12 18:09:37 +01:00
|
|
|
}
|
|
|
|
|
2014-02-12 23:10:23 +00:00
|
|
|
void test_multiple_threads ()
|
2013-09-12 18:09:37 +01:00
|
|
|
{
|
2013-09-12 21:07:29 +01:00
|
|
|
const unsigned int no_of_threads = 30;
|
2013-09-12 18:09:37 +01:00
|
|
|
|
|
|
|
void *threads[no_of_threads];
|
|
|
|
|
|
|
|
// Connect first
|
|
|
|
for (unsigned int i = 0; i < no_of_threads; ++i) {
|
2018-05-23 13:48:58 +02:00
|
|
|
threads[i] = zmq_threadstart (&pusher, NULL);
|
2013-09-12 18:09:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Now bind
|
2018-05-27 07:01:36 -04:00
|
|
|
void *bind_socket = test_context_socket (ZMQ_PULL);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (bind_socket, "inproc://sink"));
|
2013-09-12 18:09:37 +01:00
|
|
|
|
|
|
|
for (unsigned int i = 0; i < no_of_threads; ++i) {
|
|
|
|
// Read pending message
|
2018-05-27 07:01:36 -04:00
|
|
|
recv_string_expect_success (bind_socket, "foobar", 0);
|
2013-09-12 18:09:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Cleanup
|
|
|
|
for (unsigned int i = 0; i < no_of_threads; ++i) {
|
|
|
|
zmq_threadclose (threads[i]);
|
|
|
|
}
|
|
|
|
|
2018-05-27 07:01:36 -04:00
|
|
|
test_context_socket_close (bind_socket);
|
2013-09-12 18:09:37 +01:00
|
|
|
}
|
|
|
|
|
2014-05-09 11:46:17 -07:00
|
|
|
void test_simultaneous_connect_bind_threads ()
|
|
|
|
{
|
|
|
|
const unsigned int no_of_times = 50;
|
|
|
|
void *threads[no_of_times * 2];
|
2018-05-23 13:48:58 +02:00
|
|
|
void *thr_args[no_of_times];
|
2014-05-09 11:46:17 -07:00
|
|
|
char endpts[no_of_times][20];
|
|
|
|
|
|
|
|
// Set up thread arguments: context followed by endpoint string
|
|
|
|
for (unsigned int i = 0; i < no_of_times; ++i) {
|
2018-05-23 13:48:58 +02:00
|
|
|
thr_args[i] = (void *) endpts[i];
|
2014-05-09 11:46:17 -07:00
|
|
|
sprintf (endpts[i], "inproc://foo_%d", i);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Spawn all threads as simultaneously as possible
|
|
|
|
for (unsigned int i = 0; i < no_of_times; ++i) {
|
2019-12-08 14:26:57 +01:00
|
|
|
threads[i * 2 + 0] = zmq_threadstart (&simult_conn, thr_args[i]);
|
|
|
|
threads[i * 2 + 1] = zmq_threadstart (&simult_bind, thr_args[i]);
|
2014-05-09 11:46:17 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Close all threads
|
|
|
|
for (unsigned int i = 0; i < no_of_times; ++i) {
|
|
|
|
zmq_threadclose (threads[i * 2 + 0]);
|
|
|
|
zmq_threadclose (threads[i * 2 + 1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-07 11:21:13 +02:00
|
|
|
void test_routing_id ()
|
2013-09-12 21:07:29 +01:00
|
|
|
{
|
|
|
|
// Create the infrastructure
|
2018-05-23 13:48:58 +02:00
|
|
|
void *sc = test_context_socket (ZMQ_DEALER);
|
2014-02-12 23:10:23 +00:00
|
|
|
|
2018-05-23 13:48:58 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, "inproc://routing_id"));
|
2014-02-12 23:10:23 +00:00
|
|
|
|
2018-05-23 13:48:58 +02:00
|
|
|
void *sb = test_context_socket (ZMQ_ROUTER);
|
2014-02-12 23:10:23 +00:00
|
|
|
|
2018-05-23 13:48:58 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, "inproc://routing_id"));
|
2013-09-12 21:07:29 +01:00
|
|
|
|
|
|
|
// Send 2-part message.
|
2018-05-23 13:48:58 +02:00
|
|
|
TEST_ASSERT_EQUAL_INT (
|
|
|
|
1, TEST_ASSERT_SUCCESS_ERRNO (zmq_send (sc, "A", 1, ZMQ_SNDMORE)));
|
|
|
|
TEST_ASSERT_EQUAL_INT (
|
|
|
|
1, TEST_ASSERT_SUCCESS_ERRNO (zmq_send (sc, "B", 1, 0)));
|
2013-09-12 21:07:29 +01:00
|
|
|
|
2017-09-07 11:21:13 +02:00
|
|
|
// Routing id comes first.
|
2013-09-12 21:07:29 +01:00
|
|
|
zmq_msg_t msg;
|
2018-05-23 13:48:58 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_init (&msg));
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, sb, 0));
|
|
|
|
TEST_ASSERT_EQUAL_INT (1, zmq_msg_more (&msg));
|
2013-09-12 21:07:29 +01:00
|
|
|
|
|
|
|
// Then the first part of the message body.
|
2018-05-23 13:48:58 +02:00
|
|
|
TEST_ASSERT_EQUAL_INT (
|
|
|
|
1, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, sb, 0)));
|
|
|
|
TEST_ASSERT_EQUAL_INT (1, zmq_msg_more (&msg));
|
2013-09-12 21:07:29 +01:00
|
|
|
|
|
|
|
// And finally, the second part of the message body.
|
2018-05-23 13:48:58 +02:00
|
|
|
TEST_ASSERT_EQUAL_INT (
|
|
|
|
1, TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&msg, sb, 0)));
|
|
|
|
TEST_ASSERT_EQUAL_INT (0, zmq_msg_more (&msg));
|
2013-09-12 21:07:29 +01:00
|
|
|
|
|
|
|
// Deallocate the infrastructure.
|
2018-05-23 13:48:58 +02:00
|
|
|
test_context_socket_close (sc);
|
|
|
|
test_context_socket_close (sb);
|
2014-02-12 23:10:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_connect_only ()
|
|
|
|
{
|
2018-05-27 07:01:36 -04:00
|
|
|
void *connect_socket = test_context_socket (ZMQ_PUSH);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connect_socket, "inproc://a"));
|
2014-02-12 23:10:23 +00:00
|
|
|
|
2018-05-27 07:01:36 -04:00
|
|
|
test_context_socket_close (connect_socket);
|
2013-09-12 21:07:29 +01:00
|
|
|
}
|
|
|
|
|
2014-07-09 10:28:26 +01:00
|
|
|
|
|
|
|
void test_unbind ()
|
|
|
|
{
|
|
|
|
// Bind and unbind socket 1
|
2018-05-27 07:01:36 -04:00
|
|
|
void *bind_socket1 = test_context_socket (ZMQ_PAIR);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (bind_socket1, "inproc://unbind"));
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_unbind (bind_socket1, "inproc://unbind"));
|
2014-07-09 10:28:26 +01:00
|
|
|
|
|
|
|
// Bind socket 2
|
2018-05-27 07:01:36 -04:00
|
|
|
void *bind_socket2 = test_context_socket (ZMQ_PAIR);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (bind_socket2, "inproc://unbind"));
|
2014-07-09 10:28:26 +01:00
|
|
|
|
|
|
|
// Now connect
|
2018-05-27 07:01:36 -04:00
|
|
|
void *connect_socket = test_context_socket (ZMQ_PAIR);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connect_socket, "inproc://unbind"));
|
2014-07-09 10:28:26 +01:00
|
|
|
|
|
|
|
// Queue up some data
|
2018-05-27 07:01:36 -04:00
|
|
|
send_string_expect_success (connect_socket, "foobar", 0);
|
2014-07-09 10:28:26 +01:00
|
|
|
|
|
|
|
// Read pending message
|
2018-05-27 07:01:36 -04:00
|
|
|
recv_string_expect_success (bind_socket2, "foobar", 0);
|
2014-07-09 10:28:26 +01:00
|
|
|
|
|
|
|
// Cleanup
|
2018-05-27 07:01:36 -04:00
|
|
|
test_context_socket_close (connect_socket);
|
|
|
|
test_context_socket_close (bind_socket1);
|
|
|
|
test_context_socket_close (bind_socket2);
|
2014-07-09 10:28:26 +01:00
|
|
|
}
|
|
|
|
|
2015-08-21 10:06:54 +01:00
|
|
|
void test_shutdown_during_pend ()
|
|
|
|
{
|
|
|
|
// Connect first
|
2018-05-27 07:01:36 -04:00
|
|
|
void *connect_socket = test_context_socket (ZMQ_PAIR);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (connect_socket, "inproc://cbb"));
|
2015-08-21 10:06:54 +01:00
|
|
|
|
2018-05-23 13:48:58 +02:00
|
|
|
zmq_ctx_shutdown (get_test_context ());
|
2015-08-21 10:06:54 +01:00
|
|
|
|
|
|
|
// Cleanup
|
2018-05-27 07:01:36 -04:00
|
|
|
test_context_socket_close (connect_socket);
|
2015-08-21 10:06:54 +01:00
|
|
|
}
|
|
|
|
|
2013-09-12 14:44:44 +01:00
|
|
|
int main (void)
|
|
|
|
{
|
2014-02-12 23:10:23 +00:00
|
|
|
setup_test_environment ();
|
2013-09-12 14:44:44 +01:00
|
|
|
|
2018-05-23 13:48:58 +02:00
|
|
|
UNITY_BEGIN ();
|
|
|
|
RUN_TEST (test_bind_before_connect);
|
|
|
|
RUN_TEST (test_connect_before_bind);
|
|
|
|
RUN_TEST (test_connect_before_bind_pub_sub);
|
|
|
|
RUN_TEST (test_connect_before_bind_ctx_term);
|
|
|
|
RUN_TEST (test_multiple_connects);
|
|
|
|
RUN_TEST (test_multiple_threads);
|
|
|
|
RUN_TEST (test_simultaneous_connect_bind_threads);
|
|
|
|
RUN_TEST (test_routing_id);
|
|
|
|
RUN_TEST (test_connect_only);
|
|
|
|
RUN_TEST (test_unbind);
|
|
|
|
RUN_TEST (test_shutdown_during_pend);
|
|
|
|
return UNITY_END ();
|
2013-09-12 14:44:44 +01:00
|
|
|
}
|