2023-06-05 00:16:05 +01:00
|
|
|
/* SPDX-License-Identifier: MPL-2.0 */
|
2013-10-30 16:03:27 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "testutil.hpp"
|
|
|
|
|
2019-03-22 06:48:49 -04:00
|
|
|
#include "testutil_unity.hpp"
|
|
|
|
|
2019-03-24 12:51:28 -04:00
|
|
|
SETUP_TEARDOWN_TESTCONTEXT
|
2013-10-30 16:03:27 +01:00
|
|
|
|
2019-03-22 06:48:49 -04:00
|
|
|
void test_router_mandatory_tipc ()
|
|
|
|
{
|
|
|
|
if (!is_tipc_available ()) {
|
|
|
|
TEST_IGNORE_MESSAGE ("TIPC environment unavailable, skipping test");
|
|
|
|
}
|
2013-10-30 16:03:27 +01:00
|
|
|
|
|
|
|
// Creating the first socket.
|
2019-03-22 06:48:49 -04:00
|
|
|
void *sa = test_context_socket (ZMQ_ROUTER);
|
2013-10-30 16:03:27 +01:00
|
|
|
|
2019-03-22 06:48:49 -04:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sa, "tipc://{15560,0,0}"));
|
2013-10-30 16:03:27 +01:00
|
|
|
|
|
|
|
// Sending a message to an unknown peer with the default setting
|
2019-03-22 06:48:49 -04:00
|
|
|
send_string_expect_success (sa, "UNKNOWN", ZMQ_SNDMORE);
|
|
|
|
send_string_expect_success (sa, "DATA", 0);
|
2013-10-30 16:03:27 +01:00
|
|
|
|
|
|
|
int mandatory = 1;
|
|
|
|
|
|
|
|
// Set mandatory routing on socket
|
2019-03-22 06:48:49 -04:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_setsockopt (sa, ZMQ_ROUTER_MANDATORY,
|
|
|
|
&mandatory, sizeof (mandatory)));
|
2013-10-30 16:03:27 +01:00
|
|
|
|
|
|
|
// Send a message and check that it fails
|
2019-03-22 06:48:49 -04:00
|
|
|
TEST_ASSERT_FAILURE_ERRNO (
|
|
|
|
EHOSTUNREACH, zmq_send (sa, "UNKNOWN", 7, ZMQ_SNDMORE | ZMQ_DONTWAIT));
|
2013-10-30 16:03:27 +01:00
|
|
|
|
2019-03-22 06:48:49 -04:00
|
|
|
test_context_socket_close (sa);
|
|
|
|
}
|
2013-10-30 16:03:27 +01:00
|
|
|
|
2019-03-22 06:48:49 -04:00
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
UNITY_BEGIN ();
|
|
|
|
RUN_TEST (test_router_mandatory_tipc);
|
|
|
|
return UNITY_END ();
|
2013-10-30 16:03:27 +01:00
|
|
|
}
|