2023-06-05 01:16:05 +02:00
|
|
|
/* SPDX-License-Identifier: MPL-2.0 */
|
2013-10-04 01:35:30 +02:00
|
|
|
|
|
|
|
#include "testutil.hpp"
|
2018-12-07 13:51:30 +01:00
|
|
|
#include "testutil_unity.hpp"
|
2013-10-04 01:35:30 +02:00
|
|
|
|
2019-03-23 13:04:57 +01:00
|
|
|
#include <string.h>
|
2018-12-07 13:51:30 +01:00
|
|
|
|
2019-03-24 17:51:28 +01:00
|
|
|
SETUP_TEARDOWN_TESTCONTEXT
|
2013-10-04 01:35:30 +02:00
|
|
|
|
2018-12-07 13:51:30 +01:00
|
|
|
static const char test_endpoint[] = "ipc://@tmp-tester";
|
2020-09-05 13:10:59 +02:00
|
|
|
static const char test_endpoint_empty[] = "ipc://@";
|
2013-10-04 01:35:30 +02:00
|
|
|
|
2018-12-07 13:51:30 +01:00
|
|
|
void test_roundtrip ()
|
|
|
|
{
|
|
|
|
void *sb = test_context_socket (ZMQ_DEALER);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, test_endpoint));
|
|
|
|
|
|
|
|
char endpoint[MAX_SOCKET_STRING];
|
2013-10-04 01:35:30 +02:00
|
|
|
size_t size = sizeof (endpoint);
|
2018-12-07 13:51:30 +01:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (
|
|
|
|
zmq_getsockopt (sb, ZMQ_LAST_ENDPOINT, endpoint, &size));
|
|
|
|
TEST_ASSERT_EQUAL_INT (0, strncmp (endpoint, test_endpoint, size));
|
2013-10-04 01:35:30 +02:00
|
|
|
|
2018-12-07 13:51:30 +01:00
|
|
|
void *sc = test_context_socket (ZMQ_DEALER);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, test_endpoint));
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2013-10-04 01:35:30 +02:00
|
|
|
bounce (sb, sc);
|
|
|
|
|
2018-12-07 13:51:30 +01:00
|
|
|
test_context_socket_close (sc);
|
|
|
|
test_context_socket_close (sb);
|
|
|
|
}
|
2013-10-04 01:35:30 +02:00
|
|
|
|
2020-09-05 13:10:59 +02:00
|
|
|
void test_empty_abstract_name ()
|
|
|
|
{
|
|
|
|
void *sb = test_context_socket (ZMQ_DEALER);
|
|
|
|
TEST_ASSERT_FAILURE_ERRNO (EINVAL, zmq_bind (sb, test_endpoint_empty));
|
|
|
|
|
|
|
|
test_context_socket_close (sb);
|
|
|
|
}
|
|
|
|
|
2018-12-07 13:51:30 +01:00
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
setup_test_environment ();
|
2013-10-04 01:35:30 +02:00
|
|
|
|
2018-12-07 13:51:30 +01:00
|
|
|
UNITY_BEGIN ();
|
|
|
|
RUN_TEST (test_roundtrip);
|
2020-09-05 13:10:59 +02:00
|
|
|
RUN_TEST (test_empty_abstract_name);
|
2018-12-07 13:51:30 +01:00
|
|
|
return UNITY_END ();
|
2013-10-04 01:35:30 +02:00
|
|
|
}
|