Problem: no test case for tcp name resolution no longer working

Solution: add test case
This commit is contained in:
Simon Giesecke 2019-02-07 11:00:41 +01:00
parent 84dc40dd90
commit 8de7e529ec

View File

@ -80,6 +80,36 @@ void test_pair_tcp_regular ()
test_pair_tcp ();
}
void test_pair_tcp_connect_by_name ()
{
// all other tcp test cases bind to a loopback wildcard address, then
// retrieve the bound endpoint, which is numerical, and use that to
// connect. this test cases specifically uses "localhost" to connect
// to ensure that names are correctly resolved
void *sb = test_context_socket (ZMQ_PAIR);
char bound_endpoint[MAX_SOCKET_STRING];
bind_loopback_ipv4 (sb, bound_endpoint, sizeof bound_endpoint);
// extract the bound port number
const char *pos = strrchr (bound_endpoint, ':');
TEST_ASSERT_NOT_NULL (pos);
const char connect_endpoint_prefix[] = "tcp://localhost";
char connect_endpoint[MAX_SOCKET_STRING];
strcpy (connect_endpoint, connect_endpoint_prefix);
strcat (connect_endpoint, pos);
void *sc = test_context_socket (ZMQ_PAIR);
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, connect_endpoint));
bounce (sb, sc);
test_context_socket_close (sc);
test_context_socket_close (sb);
}
#ifdef ZMQ_BUILD_DRAFT
void test_pair_tcp_fastpath ()
{
@ -93,6 +123,7 @@ int main ()
UNITY_BEGIN ();
RUN_TEST (test_pair_tcp_regular);
RUN_TEST (test_pair_tcp_connect_by_name);
#ifdef ZMQ_BUILD_DRAFT
RUN_TEST (test_pair_tcp_fastpath);
#endif