2023-06-05 01:16:05 +02:00
|
|
|
/* SPDX-License-Identifier: MPL-2.0 */
|
2017-10-05 23:29:25 +02:00
|
|
|
|
|
|
|
#include "testutil.hpp"
|
2018-12-10 12:04:38 +01:00
|
|
|
#include "testutil_unity.hpp"
|
2017-10-05 23:29:25 +02:00
|
|
|
|
2019-03-24 17:51:28 +01:00
|
|
|
SETUP_TEARDOWN_TESTCONTEXT
|
2017-10-05 23:29:25 +02:00
|
|
|
|
2018-12-10 12:04:38 +01:00
|
|
|
void test_rebind_ipc ()
|
|
|
|
{
|
2019-10-19 14:46:53 +02:00
|
|
|
char my_endpoint[MAX_SOCKET_STRING];
|
2019-02-04 11:33:28 +01:00
|
|
|
make_random_ipc_endpoint (my_endpoint);
|
2019-01-13 15:50:07 +01:00
|
|
|
|
2018-12-10 12:04:38 +01:00
|
|
|
void *sb0 = test_context_socket (ZMQ_PUSH);
|
|
|
|
void *sb1 = test_context_socket (ZMQ_PUSH);
|
2017-10-05 23:29:25 +02:00
|
|
|
|
2019-01-14 01:10:08 +01:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb0, my_endpoint));
|
2017-10-05 23:29:25 +02:00
|
|
|
|
2018-12-10 12:04:38 +01:00
|
|
|
void *sc = test_context_socket (ZMQ_PULL);
|
2019-01-13 15:50:07 +01:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, my_endpoint));
|
2017-10-05 23:29:25 +02:00
|
|
|
|
2018-12-10 12:04:38 +01:00
|
|
|
send_string_expect_success (sb0, "42", 0);
|
|
|
|
recv_string_expect_success (sc, "42", 0);
|
2017-10-05 23:29:25 +02:00
|
|
|
|
2018-12-10 12:04:38 +01:00
|
|
|
test_context_socket_close (sb0);
|
2017-10-05 23:29:25 +02:00
|
|
|
|
2019-01-13 15:50:07 +01:00
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb1, my_endpoint));
|
2017-10-05 23:29:25 +02:00
|
|
|
|
2018-12-10 12:04:38 +01:00
|
|
|
send_string_expect_success (sb1, "42", 0);
|
|
|
|
recv_string_expect_success (sc, "42", 0);
|
2017-10-05 23:29:25 +02:00
|
|
|
|
2018-12-10 12:04:38 +01:00
|
|
|
test_context_socket_close (sc);
|
|
|
|
test_context_socket_close (sb1);
|
|
|
|
}
|
2017-10-05 23:29:25 +02:00
|
|
|
|
2018-12-10 12:04:38 +01:00
|
|
|
int main ()
|
|
|
|
{
|
|
|
|
setup_test_environment ();
|
2017-10-05 23:29:25 +02:00
|
|
|
|
2018-12-10 12:04:38 +01:00
|
|
|
UNITY_BEGIN ();
|
|
|
|
RUN_TEST (test_rebind_ipc);
|
|
|
|
return UNITY_END ();
|
2017-10-05 23:29:25 +02:00
|
|
|
}
|