test_router_mandatory_tipc.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 
3 #include <stdio.h>
4 #include "testutil.hpp"
5 
6 #include "testutil_unity.hpp"
7 
9 
11 {
12  if (!is_tipc_available ()) {
13  TEST_IGNORE_MESSAGE ("TIPC environment unavailable, skipping test");
14  }
15 
16  // Creating the first socket.
17  void *sa = test_context_socket (ZMQ_ROUTER);
18 
19  TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sa, "tipc://{15560,0,0}"));
20 
21  // Sending a message to an unknown peer with the default setting
22  send_string_expect_success (sa, "UNKNOWN", ZMQ_SNDMORE);
23  send_string_expect_success (sa, "DATA", 0);
24 
25  int mandatory = 1;
26 
27  // Set mandatory routing on socket
29  &mandatory, sizeof (mandatory)));
30 
31  // Send a message and check that it fails
33  EHOSTUNREACH, zmq_send (sa, "UNKNOWN", 7, ZMQ_SNDMORE | ZMQ_DONTWAIT));
34 
36 }
37 
38 int main (void)
39 {
40  UNITY_BEGIN ();
42  return UNITY_END ();
43 }
main
int main(void)
Definition: test_router_mandatory_tipc.cpp:38
UNITY_END
return UNITY_END()
RUN_TEST
#define RUN_TEST(func)
Definition: unity_internals.h:615
SETUP_TEARDOWN_TESTCONTEXT
#define SETUP_TEARDOWN_TESTCONTEXT
Definition: testutil_unity.hpp:172
testutil_unity.hpp
zmq_setsockopt
ZMQ_EXPORT int zmq_setsockopt(void *s_, int option_, const void *optval_, size_t optvallen_)
Definition: zmq.cpp:250
testutil.hpp
ZMQ_ROUTER
#define ZMQ_ROUTER
Definition: zmq.h:264
zmq_bind
ZMQ_EXPORT int zmq_bind(void *s_, const char *addr_)
Definition: zmq.cpp:299
is_tipc_available
int is_tipc_available()
Definition: testutil.cpp:283
test_context_socket
void * test_context_socket(int type_)
Definition: testutil_unity.cpp:200
ZMQ_DONTWAIT
#define ZMQ_DONTWAIT
Definition: zmq.h:358
ZMQ_ROUTER_MANDATORY
#define ZMQ_ROUTER_MANDATORY
Definition: zmq.h:299
TEST_IGNORE_MESSAGE
#define TEST_IGNORE_MESSAGE(message)
Definition: unity.h:103
send_string_expect_success
void send_string_expect_success(void *socket_, const char *str_, int flags_)
Definition: testutil_unity.cpp:94
UNITY_BEGIN
UNITY_BEGIN()
ZMQ_SNDMORE
#define ZMQ_SNDMORE
Definition: zmq.h:359
TEST_ASSERT_FAILURE_ERRNO
#define TEST_ASSERT_FAILURE_ERRNO(error_code, expr)
Definition: testutil_unity.hpp:95
EHOSTUNREACH
#define EHOSTUNREACH
Definition: zmq.h:152
test_router_mandatory_tipc
SETUP_TEARDOWN_TESTCONTEXT void test_router_mandatory_tipc()
Definition: test_router_mandatory_tipc.cpp:10
zmq_send
ZMQ_EXPORT int zmq_send(void *s_, const void *buf_, size_t len_, int flags_)
Definition: zmq.cpp:377
test_context_socket_close
void * test_context_socket_close(void *socket_)
Definition: testutil_unity.cpp:208
TEST_ASSERT_SUCCESS_ERRNO
#define TEST_ASSERT_SUCCESS_ERRNO(expr)
Definition: proxy_thr.cpp:47


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:59