Commit fce18385 authored by Simon Giesecke's avatar Simon Giesecke

Problem: test_pair_tcp not yet using unity

Solution: migrate to unity
parent d7e51cdf
...@@ -468,7 +468,8 @@ tests_test_pair_inproc_LDADD = src/libzmq.la ...@@ -468,7 +468,8 @@ tests_test_pair_inproc_LDADD = src/libzmq.la
tests_test_pair_tcp_SOURCES = \ tests_test_pair_tcp_SOURCES = \
tests/test_pair_tcp.cpp \ tests/test_pair_tcp.cpp \
tests/testutil.hpp tests/testutil.hpp
tests_test_pair_tcp_LDADD = src/libzmq.la tests_test_pair_tcp_LDADD = src/libzmq.la ${UNITY_LIBS}
tests_test_pair_tcp_CPPFLAGS = ${UNITY_CPPFLAGS}
tests_test_reqrep_inproc_SOURCES = \ tests_test_reqrep_inproc_SOURCES = \
tests/test_reqrep_inproc.cpp \ tests/test_reqrep_inproc.cpp \
......
...@@ -28,6 +28,18 @@ ...@@ -28,6 +28,18 @@
*/ */
#include "testutil.hpp" #include "testutil.hpp"
#include "testutil_unity.hpp"
void setUp ()
{
setup_test_context ();
}
void tearDown ()
{
teardown_test_context ();
}
typedef void (*extra_func_t) (void *socket_); typedef void (*extra_func_t) (void *socket_);
...@@ -43,50 +55,47 @@ void set_sockopt_fastpath (void *socket) ...@@ -43,50 +55,47 @@ void set_sockopt_fastpath (void *socket)
void test_pair_tcp (extra_func_t extra_func_ = NULL) void test_pair_tcp (extra_func_t extra_func_ = NULL)
{ {
size_t len = MAX_SOCKET_STRING; void *sb = test_context_socket (ZMQ_PAIR);
char my_endpoint[MAX_SOCKET_STRING];
void *ctx = zmq_ctx_new ();
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_PAIR);
assert (sb);
if (extra_func_) if (extra_func_)
extra_func_ (sb); extra_func_ (sb);
int rc = zmq_bind (sb, "tcp://127.0.0.1:*"); char my_endpoint[MAX_SOCKET_STRING];
assert (rc == 0); bind_loopback_ipv4 (sb, my_endpoint, sizeof my_endpoint);
rc = zmq_getsockopt (sb, ZMQ_LAST_ENDPOINT, my_endpoint, &len);
assert (rc == 0);
void *sc = zmq_socket (ctx, ZMQ_PAIR); void *sc = test_context_socket (ZMQ_PAIR);
assert (sc);
if (extra_func_) if (extra_func_)
extra_func_ (sc); extra_func_ (sc);
rc = zmq_connect (sc, my_endpoint); TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, my_endpoint));
assert (rc == 0);
bounce (sb, sc); bounce (sb, sc);
rc = zmq_close (sc); test_context_socket_close (sc);
assert (rc == 0); test_context_socket_close (sb);
}
rc = zmq_close (sb); void test_pair_tcp_regular ()
assert (rc == 0); {
test_pair_tcp ();
}
rc = zmq_ctx_term (ctx); #ifdef ZMQ_BUILD_DRAFT
assert (rc == 0); void test_pair_tcp_fastpath ()
{
test_pair_tcp (set_sockopt_fastpath);
} }
#endif
int main (void) int main ()
{ {
setup_test_environment (); setup_test_environment ();
test_pair_tcp (); UNITY_BEGIN ();
RUN_TEST (test_pair_tcp_regular);
#ifdef ZMQ_BUILD_DRAFT #ifdef ZMQ_BUILD_DRAFT
test_pair_tcp (set_sockopt_fastpath); RUN_TEST (test_pair_tcp_fastpath);
#endif #endif
return 0; return UNITY_END ();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment