diff --git a/tests/test_abstract_ipc.cpp b/tests/test_abstract_ipc.cpp index c44bf9f3..f01d8bda 100644 --- a/tests/test_abstract_ipc.cpp +++ b/tests/test_abstract_ipc.cpp @@ -35,6 +35,7 @@ SETUP_TEARDOWN_TESTCONTEXT static const char test_endpoint[] = "ipc://@tmp-tester"; +static const char test_endpoint_empty[] = "ipc://@"; void test_roundtrip () { @@ -56,11 +57,20 @@ void test_roundtrip () test_context_socket_close (sb); } +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); +} + int main (void) { setup_test_environment (); UNITY_BEGIN (); RUN_TEST (test_roundtrip); + RUN_TEST (test_empty_abstract_name); return UNITY_END (); } diff --git a/tests/test_pair_ipc.cpp b/tests/test_pair_ipc.cpp index 81cad180..1872fd81 100644 --- a/tests/test_pair_ipc.cpp +++ b/tests/test_pair_ipc.cpp @@ -30,6 +30,8 @@ #include "testutil.hpp" #include "testutil_unity.hpp" +#include + SETUP_TEARDOWN_TESTCONTEXT void test_roundtrip () @@ -48,11 +50,32 @@ void test_roundtrip () test_context_socket_close (sb); } +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); +} + + int main (void) { setup_test_environment (); UNITY_BEGIN (); RUN_TEST (test_roundtrip); + RUN_TEST (test_endpoint_too_long); return UNITY_END (); }