test_address_tipc.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MPL-2.0 */
2 
3 #include "testutil.hpp"
4 #include "testutil_unity.hpp"
5 
7 
9 {
10  // test Port Name addressing
11  void *sb = test_context_socket (ZMQ_REP);
12  TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, "tipc://{5560,0,0}"));
13 
14  void *sc = test_context_socket (ZMQ_REQ);
15  TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, "tipc://{5560,0}@0.0.0"));
16 
17  bounce (sb, sc);
18 
21 }
22 
24 {
25  char endpoint[256];
26  unsigned int z, c, n, ref;
27 
28  void *sb = test_context_socket (ZMQ_REP);
29  void *sc = test_context_socket (ZMQ_REQ);
30 
31  // Test binding to random Port Identity and
32  // test resolving assigned address, should return a properly formatted string
33  bind_loopback_tipc (sb, endpoint, sizeof endpoint);
34 
35  int rc = sscanf (&endpoint[0], "tipc://<%u.%u.%u:%u>", &z, &c, &n, &ref);
36  TEST_ASSERT_EQUAL_INT (4, rc);
37 
39  0, ref, "tipc port number must not be 0 after random assignment");
40 
42 
43  bounce (sb, sc);
44 
47 }
48 
50 {
51  // Test Port Name addressing
52  void *sb = test_context_socket (ZMQ_REP);
53 
54  // Test binding to a fixed address, should fail
55  TEST_ASSERT_FAILURE_ERRNO (EINVAL, zmq_bind (sb, "tipc://<1.2.3:123123>"));
56 
57  // Test connecting to random identity, should fail
59 
60  // Clean up
62 }
63 
64 
65 int main ()
66 {
68 
69  if (!is_tipc_available ()) {
70  printf ("TIPC environment unavailable, skipping test\n");
71  return 77;
72  }
73 
74  UNITY_BEGIN ();
78 
79  return UNITY_END ();
80 }
bounce
static void bounce(void *socket_)
Definition: test_req_relaxed.cpp:50
bind_loopback_tipc
void bind_loopback_tipc(void *socket_, char *my_endpoint_, size_t len_)
Definition: testutil_unity.cpp:265
UNITY_END
return UNITY_END()
EINVAL
#define EINVAL
Definition: errno.hpp:25
RUN_TEST
#define RUN_TEST(func)
Definition: unity_internals.h:615
SETUP_TEARDOWN_TESTCONTEXT
#define SETUP_TEARDOWN_TESTCONTEXT
Definition: testutil_unity.hpp:172
TEST_ASSERT_NOT_EQUAL_MESSAGE
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message)
Definition: unity.h:326
ZMQ_REQ
#define ZMQ_REQ
Definition: zmq.h:261
zmq_connect
ZMQ_EXPORT int zmq_connect(void *s_, const char *addr_)
Definition: zmq.cpp:307
testutil_unity.hpp
sb
void * sb
Definition: test_channel.cpp:8
testutil.hpp
test_tipc_bad_addresses
void test_tipc_bad_addresses()
Definition: test_address_tipc.cpp:49
ZMQ_REP
#define ZMQ_REP
Definition: zmq.h:262
test_tipc_port_identity
void test_tipc_port_identity()
Definition: test_address_tipc.cpp:23
zmq_bind
ZMQ_EXPORT int zmq_bind(void *s_, const char *addr_)
Definition: zmq.cpp:299
sc
void * sc
Definition: test_channel.cpp:9
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
TEST_ASSERT_EQUAL_INT
#define TEST_ASSERT_EQUAL_INT(expected, actual)
Definition: unity.h:128
n
GLdouble n
Definition: glcorearb.h:4153
z
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:3117
test_tipc_port_name_and_domain
SETUP_TEARDOWN_TESTCONTEXT void test_tipc_port_name_and_domain()
Definition: test_address_tipc.cpp:8
setup_test_environment
void setup_test_environment(int timeout_seconds_)
Definition: testutil.cpp:201
UNITY_BEGIN
UNITY_BEGIN()
TEST_ASSERT_FAILURE_ERRNO
#define TEST_ASSERT_FAILURE_ERRNO(error_code, expr)
Definition: testutil_unity.hpp:95
test_context_socket_close
void * test_context_socket_close(void *socket_)
Definition: testutil_unity.cpp:208
ref
GLint ref
Definition: glcorearb.h:2789
TEST_ASSERT_SUCCESS_ERRNO
#define TEST_ASSERT_SUCCESS_ERRNO(expr)
Definition: proxy_thr.cpp:47
main
int main()
Definition: test_address_tipc.cpp:65


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