2023-06-05 00:16:05 +01:00
|
|
|
/* SPDX-License-Identifier: MPL-2.0 */
|
2010-08-27 18:35:59 +02:00
|
|
|
|
2010-08-28 13:58:23 +02:00
|
|
|
#include "testutil.hpp"
|
2018-12-10 06:04:38 -05:00
|
|
|
#include "testutil_unity.hpp"
|
2010-08-28 13:58:23 +02:00
|
|
|
|
2020-09-05 13:16:59 +02:00
|
|
|
#include <string>
|
|
|
|
|
2019-03-24 12:51:28 -04:00
|
|
|
SETUP_TEARDOWN_TESTCONTEXT
|
2011-03-24 10:03:49 +01:00
|
|
|
|
2018-12-10 06:04:38 -05:00
|
|
|
void test_roundtrip ()
|
|
|
|
{
|
2019-01-13 14:50:07 +00:00
|
|
|
char my_endpoint[256];
|
|
|
|
|
2018-12-10 06:04:38 -05:00
|
|
|
void *sb = test_context_socket (ZMQ_PAIR);
|
2019-03-24 13:19:36 -04:00
|
|
|
bind_loopback_ipc (sb, my_endpoint, sizeof my_endpoint);
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2018-12-10 06:04:38 -05:00
|
|
|
void *sc = test_context_socket (ZMQ_PAIR);
|
2019-01-13 14:50:07 +00:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, my_endpoint));
|
2011-03-24 10:03:49 +01:00
|
|
|
|
2018-12-10 06:04:38 -05:00
|
|
|
bounce (sb, sc);
|
2011-03-24 10:03:49 +01:00
|
|
|
|
2018-12-10 06:04:38 -05:00
|
|
|
test_context_socket_close (sc);
|
|
|
|
test_context_socket_close (sb);
|
|
|
|
}
|
2011-03-24 10:03:49 +01:00
|
|
|
|
2020-09-05 13:16:59 +02:00
|
|
|
static const char prefix[] = "ipc://";
|
|
|
|
|
|
|
|
void test_endpoint_too_long ()
|
|
|
|
{
|
|
|
|
std::string endpoint_too_long;
|
|
|
|
endpoint_too_long.append (prefix);
|
|
|
|
for (size_t i = 0; i < 108; ++i) {
|
|
|
|
endpoint_too_long.append ("a");
|
|
|
|
}
|
|
|
|
|
|
|
|
void *sb = test_context_socket (ZMQ_PAIR);
|
|
|
|
// TODO ENAMETOOLONG is not listed in the errors returned by zmq_bind,
|
|
|
|
// should this be EINVAL?
|
|
|
|
TEST_ASSERT_FAILURE_ERRNO (ENAMETOOLONG,
|
|
|
|
zmq_bind (sb, endpoint_too_long.data ()));
|
|
|
|
|
|
|
|
test_context_socket_close (sb);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-10 06:04:38 -05:00
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
setup_test_environment ();
|
2011-03-24 10:03:49 +01:00
|
|
|
|
2018-12-10 06:04:38 -05:00
|
|
|
UNITY_BEGIN ();
|
|
|
|
RUN_TEST (test_roundtrip);
|
2020-09-05 13:16:59 +02:00
|
|
|
RUN_TEST (test_endpoint_too_long);
|
2018-12-10 06:04:38 -05:00
|
|
|
return UNITY_END ();
|
2010-08-27 18:35:59 +02:00
|
|
|
}
|