2023-06-05 01:16:05 +02:00
|
|
|
/* SPDX-License-Identifier: MPL-2.0 */
|
2013-10-28 21:00:42 +01:00
|
|
|
|
|
|
|
#include "testutil.hpp"
|
2018-08-20 17:08:13 +02:00
|
|
|
#include "testutil_unity.hpp"
|
2013-10-28 21:00:42 +01:00
|
|
|
|
2019-03-24 17:51:28 +01:00
|
|
|
SETUP_TEARDOWN_TESTCONTEXT
|
2018-08-20 17:08:13 +02:00
|
|
|
|
|
|
|
void test_stream_empty ()
|
2013-10-28 21:00:42 +01:00
|
|
|
{
|
2017-05-01 13:11:11 +02:00
|
|
|
char my_endpoint[MAX_SOCKET_STRING];
|
2018-08-20 17:08:13 +02:00
|
|
|
|
|
|
|
void *stream = test_context_socket (ZMQ_STREAM);
|
|
|
|
void *dealer = test_context_socket (ZMQ_DEALER);
|
|
|
|
|
|
|
|
bind_loopback_ipv4 (stream, my_endpoint, sizeof my_endpoint);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (dealer, my_endpoint));
|
|
|
|
send_string_expect_success (dealer, "", 0);
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2013-10-28 21:00:42 +01:00
|
|
|
zmq_msg_t ident, empty;
|
|
|
|
zmq_msg_init (&ident);
|
2018-08-20 17:08:13 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_recv (&ident, stream, 0));
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (
|
|
|
|
zmq_msg_init_data (&empty, (void *) "", 0, NULL, NULL));
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2018-08-20 17:08:13 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_send (&ident, stream, ZMQ_SNDMORE));
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&ident));
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2018-08-20 17:08:13 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_send (&empty, stream, 0));
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2013-10-28 21:00:42 +01:00
|
|
|
// This close used to fail with Bad Address
|
2018-08-20 17:08:13 +02:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_msg_close (&empty));
|
|
|
|
|
|
|
|
test_context_socket_close_zero_linger (dealer);
|
|
|
|
test_context_socket_close_zero_linger (stream);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main ()
|
|
|
|
{
|
|
|
|
setup_test_environment ();
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2018-08-20 17:08:13 +02:00
|
|
|
UNITY_BEGIN ();
|
|
|
|
RUN_TEST (test_stream_empty);
|
|
|
|
return UNITY_END ();
|
2013-10-28 21:00:42 +01:00
|
|
|
}
|