2023-06-05 00:16:05 +01:00
|
|
|
/* SPDX-License-Identifier: MPL-2.0 */
|
2010-08-27 18:35:59 +02:00
|
|
|
|
2010-08-28 13:58:23 +02:00
|
|
|
#include "testutil.hpp"
|
2018-12-07 07:51:30 -05:00
|
|
|
#include "testutil_unity.hpp"
|
2010-08-28 13:58:23 +02:00
|
|
|
|
2019-03-23 08:04:57 -04:00
|
|
|
#include <stdlib.h>
|
2018-12-07 07:51:30 -05:00
|
|
|
|
2019-03-24 12:51:28 -04:00
|
|
|
SETUP_TEARDOWN_TESTCONTEXT
|
2018-12-07 07:51:30 -05:00
|
|
|
|
|
|
|
void test_leak ()
|
2017-05-10 23:31:17 +01:00
|
|
|
{
|
|
|
|
char my_endpoint[256];
|
|
|
|
|
2018-12-07 07:51:30 -05:00
|
|
|
void *sb = test_context_socket (ZMQ_REP);
|
2019-03-24 13:19:36 -04:00
|
|
|
bind_loopback_ipc (sb, my_endpoint, sizeof my_endpoint);
|
2017-05-10 23:31:17 +01:00
|
|
|
|
2018-12-07 07:51:30 -05:00
|
|
|
void *sc = test_context_socket (ZMQ_REQ);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, my_endpoint));
|
2017-05-10 23:31:17 +01:00
|
|
|
|
2018-12-07 07:51:30 -05:00
|
|
|
static const char leakymsg[] = "leakymsg";
|
|
|
|
send_string_expect_success (sc, leakymsg, 0);
|
2017-05-10 23:31:17 +01:00
|
|
|
|
|
|
|
char *buf = s_recv (sb);
|
|
|
|
free (buf);
|
|
|
|
|
2018-12-07 07:51:30 -05:00
|
|
|
test_context_socket_close (sc);
|
2017-05-10 23:31:17 +01:00
|
|
|
|
|
|
|
msleep (SETTLE_TIME);
|
|
|
|
|
2018-12-07 07:51:30 -05:00
|
|
|
send_string_expect_success (sb, leakymsg, 0);
|
2017-05-10 23:31:17 +01:00
|
|
|
|
2018-12-07 07:51:30 -05:00
|
|
|
test_context_socket_close (sb);
|
2017-05-10 23:31:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void test_simple (void)
|
2010-08-27 18:35:59 +02:00
|
|
|
{
|
2017-05-01 12:23:19 +01:00
|
|
|
char my_endpoint[256];
|
2011-03-24 10:03:49 +01:00
|
|
|
|
2018-12-07 07:51:30 -05:00
|
|
|
void *sb = test_context_socket (ZMQ_REP);
|
2019-03-24 13:19:36 -04:00
|
|
|
bind_loopback_ipc (sb, my_endpoint, sizeof my_endpoint);
|
2011-03-24 10:03:49 +01:00
|
|
|
|
2018-12-07 07:51:30 -05:00
|
|
|
void *sc = test_context_socket (ZMQ_REQ);
|
|
|
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, my_endpoint));
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2011-03-24 10:03:49 +01:00
|
|
|
bounce (sb, sc);
|
|
|
|
|
2018-12-07 07:51:30 -05:00
|
|
|
test_context_socket_close (sc);
|
|
|
|
test_context_socket_close (sb);
|
2017-05-10 23:31:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
setup_test_environment ();
|
|
|
|
|
2018-12-07 07:51:30 -05:00
|
|
|
UNITY_BEGIN ();
|
|
|
|
RUN_TEST (test_simple);
|
|
|
|
RUN_TEST (test_leak);
|
|
|
|
return UNITY_END ();
|
2010-08-27 18:35:59 +02:00
|
|
|
}
|