mirror of
				https://github.com/zeromq/libzmq.git
				synced 2025-10-27 19:10:22 +01:00 
			
		
		
		
	Problem: test_pair_tcp not yet using unity
Solution: migrate to unity
This commit is contained in:
		| @@ -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 @@ | |||||||
| */ | */ | ||||||
|  |  | ||||||
| #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) | |||||||
|  |  | ||||||
| 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); |  | ||||||
|     assert (rc == 0); |  | ||||||
|  |  | ||||||
|     rc = zmq_ctx_term (ctx); |  | ||||||
|     assert (rc == 0); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| int main (void) | void test_pair_tcp_regular () | ||||||
|  | { | ||||||
|  |     test_pair_tcp (); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | #ifdef ZMQ_BUILD_DRAFT | ||||||
|  | void test_pair_tcp_fastpath () | ||||||
|  | { | ||||||
|  |     test_pair_tcp (set_sockopt_fastpath); | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | 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 (); | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Simon Giesecke
					Simon Giesecke