diff --git a/tests/test_abstract_ipc.cpp b/tests/test_abstract_ipc.cpp index de31bd06..c44bf9f3 100644 --- a/tests/test_abstract_ipc.cpp +++ b/tests/test_abstract_ipc.cpp @@ -31,17 +31,8 @@ #include "testutil_unity.hpp" #include -#include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT static const char test_endpoint[] = "ipc://@tmp-tester"; diff --git a/tests/test_bind_after_connect_tcp.cpp b/tests/test_bind_after_connect_tcp.cpp index ec02f8f9..eb2ecb1c 100644 --- a/tests/test_bind_after_connect_tcp.cpp +++ b/tests/test_bind_after_connect_tcp.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_x () { diff --git a/tests/test_bind_src_address.cpp b/tests/test_bind_src_address.cpp index 1221c3f8..8f80a3aa 100644 --- a/tests/test_bind_src_address.cpp +++ b/tests/test_bind_src_address.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_x () { diff --git a/tests/test_client_server.cpp b/tests/test_client_server.cpp index a19ae33b..39f75332 100644 --- a/tests/test_client_server.cpp +++ b/tests/test_client_server.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void create_inproc_client_server_pair (void **server_, void **client_) { diff --git a/tests/test_conflate.cpp b/tests/test_conflate.cpp index 14730cdb..533dceb2 100644 --- a/tests/test_conflate.cpp +++ b/tests/test_conflate.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_x () { diff --git a/tests/test_connect_delay_tipc.cpp b/tests/test_connect_delay_tipc.cpp index 30b08cce..8fd40f14 100644 --- a/tests/test_connect_delay_tipc.cpp +++ b/tests/test_connect_delay_tipc.cpp @@ -31,17 +31,7 @@ #include "testutil_unity.hpp" #include "testutil_security.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_send_one_connected_one_unconnected () { diff --git a/tests/test_connect_rid.cpp b/tests/test_connect_rid.cpp index 595017a4..49dbded3 100644 --- a/tests/test_connect_rid.cpp +++ b/tests/test_connect_rid.cpp @@ -32,15 +32,7 @@ #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT const char *rconn1routing_id = "conn1"; const char *x_routing_id = "X"; diff --git a/tests/test_ctx_options.cpp b/tests/test_ctx_options.cpp index dd2807fe..53fe35f5 100644 --- a/tests/test_ctx_options.cpp +++ b/tests/test_ctx_options.cpp @@ -31,15 +31,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT #define WAIT_FOR_BACKGROUND_THREAD_INSPECTION (0) diff --git a/tests/test_dgram.cpp b/tests/test_dgram.cpp index 56d37be9..e4f1cf58 100644 --- a/tests/test_dgram.cpp +++ b/tests/test_dgram.cpp @@ -32,17 +32,8 @@ #include #include -#include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void str_send_to (void *s_, const char *content_, const char *address_) { diff --git a/tests/test_diffserv.cpp b/tests/test_diffserv.cpp index 56d069d6..4ed6dc62 100644 --- a/tests/test_diffserv.cpp +++ b/tests/test_diffserv.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_diffserv () { diff --git a/tests/test_disconnect_inproc.cpp b/tests/test_disconnect_inproc.cpp index a3cd5ce6..401a18d7 100644 --- a/tests/test_disconnect_inproc.cpp +++ b/tests/test_disconnect_inproc.cpp @@ -32,15 +32,7 @@ #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT /// Initialize a zeromq message with a given null-terminated string #define ZMQ_PREPARE_STRING(msg, data, size) \ diff --git a/tests/test_filter_ipc.cpp b/tests/test_filter_ipc.cpp index b0b65082..57fdd949 100644 --- a/tests/test_filter_ipc.cpp +++ b/tests/test_filter_ipc.cpp @@ -33,15 +33,7 @@ #include #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT static void bounce_fail (void *server_, void *client_) { diff --git a/tests/test_fork.cpp b/tests/test_fork.cpp index ebcf5bca..212a65c4 100644 --- a/tests/test_fork.cpp +++ b/tests/test_fork.cpp @@ -36,15 +36,7 @@ #include #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT char connect_address[MAX_SOCKET_STRING]; diff --git a/tests/test_getsockopt_memset.cpp b/tests/test_getsockopt_memset.cpp index f90df9b4..caab9c27 100644 --- a/tests/test_getsockopt_memset.cpp +++ b/tests/test_getsockopt_memset.cpp @@ -26,15 +26,8 @@ #include "testutil_unity.hpp" #include -void setUp () -{ - setup_test_context (); -} -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_getsockopt_memset () { diff --git a/tests/test_heartbeats.cpp b/tests/test_heartbeats.cpp index 8ecc3f6f..c7033c13 100644 --- a/tests/test_heartbeats.cpp +++ b/tests/test_heartbeats.cpp @@ -42,16 +42,7 @@ typedef int raw_socket; #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} - +SETUP_TEARDOWN_TESTCONTEXT // Read one event off the monitor socket; return value and address // by reference, if not null, and event number by value. Returns -1 diff --git a/tests/test_hwm.cpp b/tests/test_hwm.cpp index 1ccf7338..e07d1888 100644 --- a/tests/test_hwm.cpp +++ b/tests/test_hwm.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT const int MAX_SENDS = 10000; diff --git a/tests/test_hwm_pubsub.cpp b/tests/test_hwm_pubsub.cpp index bb634097..c88a568f 100644 --- a/tests/test_hwm_pubsub.cpp +++ b/tests/test_hwm_pubsub.cpp @@ -36,15 +36,7 @@ // ensure we have extra space for that: #define SOCKET_STRING_LEN (MAX_SOCKET_STRING * 4) -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT int test_defaults (int send_hwm_, int msg_cnt_, const char *endpoint) { diff --git a/tests/test_immediate.cpp b/tests/test_immediate.cpp index 31262f30..bbb9927d 100644 --- a/tests/test_immediate.cpp +++ b/tests/test_immediate.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_immediate_1 () { diff --git a/tests/test_inproc_connect.cpp b/tests/test_inproc_connect.cpp index cc1b16e4..5f903b2f 100644 --- a/tests/test_inproc_connect.cpp +++ b/tests/test_inproc_connect.cpp @@ -30,15 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT static void pusher (void * /*unused*/) { diff --git a/tests/test_invalid_rep.cpp b/tests/test_invalid_rep.cpp index 059c3dac..ae9fb18b 100644 --- a/tests/test_invalid_rep.cpp +++ b/tests/test_invalid_rep.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_invalid_rep () { diff --git a/tests/test_iov.cpp b/tests/test_iov.cpp index 66d5bbcd..f9ccbafc 100644 --- a/tests/test_iov.cpp +++ b/tests/test_iov.cpp @@ -32,17 +32,8 @@ #include #include -#include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT // XSI vector I/O #if defined ZMQ_HAVE_UIO diff --git a/tests/test_ipc_wildcard.cpp b/tests/test_ipc_wildcard.cpp index e7444cd1..ff369615 100644 --- a/tests/test_ipc_wildcard.cpp +++ b/tests/test_ipc_wildcard.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_ipc_wildcard () { diff --git a/tests/test_issue_566.cpp b/tests/test_issue_566.cpp index 137da19a..7a8859fe 100644 --- a/tests/test_issue_566.cpp +++ b/tests/test_issue_566.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT // Issue 566 describes a problem in libzmq v4.0.0 where a dealer to router // connection would fail randomly. The test works when the two sockets are diff --git a/tests/test_last_endpoint.cpp b/tests/test_last_endpoint.cpp index aad95ab8..663b8d71 100644 --- a/tests/test_last_endpoint.cpp +++ b/tests/test_last_endpoint.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT static void do_bind_and_verify (void *s_, const char *endpoint_) { diff --git a/tests/test_many_sockets.cpp b/tests/test_many_sockets.cpp index 6b3336ac..62b27196 100644 --- a/tests/test_many_sockets.cpp +++ b/tests/test_many_sockets.cpp @@ -34,15 +34,7 @@ #include #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_system_max () { diff --git a/tests/test_mock_pub_sub.cpp b/tests/test_mock_pub_sub.cpp index c8a01fc0..cac5d50a 100644 --- a/tests/test_mock_pub_sub.cpp +++ b/tests/test_mock_pub_sub.cpp @@ -34,15 +34,7 @@ typedef int raw_socket; #include #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT // Read one event off the monitor socket; return value and address // by reference, if not null, and event number by value. Returns -1 diff --git a/tests/test_monitor.cpp b/tests/test_monitor.cpp index a484c052..0aa9af0b 100644 --- a/tests/test_monitor.cpp +++ b/tests/test_monitor.cpp @@ -35,15 +35,7 @@ #include #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_monitor_invalid_protocol_fails () { diff --git a/tests/test_msg_ffn.cpp b/tests/test_msg_ffn.cpp index e27d11dd..a6f5bd42 100644 --- a/tests/test_msg_ffn.cpp +++ b/tests/test_msg_ffn.cpp @@ -32,15 +32,7 @@ #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void ffn (void *data_, void *hint_) { diff --git a/tests/test_msg_flags.cpp b/tests/test_msg_flags.cpp index 5a2e1f96..55cf348b 100644 --- a/tests/test_msg_flags.cpp +++ b/tests/test_msg_flags.cpp @@ -30,15 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_more () { diff --git a/tests/test_pair_ipc.cpp b/tests/test_pair_ipc.cpp index ab4dde35..28bb20be 100644 --- a/tests/test_pair_ipc.cpp +++ b/tests/test_pair_ipc.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_roundtrip () { diff --git a/tests/test_pair_tcp.cpp b/tests/test_pair_tcp.cpp index 0b575ece..0fbb006f 100644 --- a/tests/test_pair_tcp.cpp +++ b/tests/test_pair_tcp.cpp @@ -32,16 +32,7 @@ #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} - +SETUP_TEARDOWN_TESTCONTEXT typedef void (*extra_func_t) (void *socket_); diff --git a/tests/test_pair_tcp_cap_net_admin.cpp b/tests/test_pair_tcp_cap_net_admin.cpp index d72b0fbd..1cc66410 100644 --- a/tests/test_pair_tcp_cap_net_admin.cpp +++ b/tests/test_pair_tcp_cap_net_admin.cpp @@ -30,15 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT typedef void (*extra_func_t) (void *socket_); diff --git a/tests/test_pair_tipc.cpp b/tests/test_pair_tipc.cpp index d3803fb7..9040dda0 100644 --- a/tests/test_pair_tipc.cpp +++ b/tests/test_pair_tipc.cpp @@ -31,17 +31,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_roundtrip () { diff --git a/tests/test_pair_vmci.cpp b/tests/test_pair_vmci.cpp index 850e794f..721c1ba5 100644 --- a/tests/test_pair_vmci.cpp +++ b/tests/test_pair_vmci.cpp @@ -34,15 +34,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_pair_vmci () { diff --git a/tests/test_poller.cpp b/tests/test_poller.cpp index d1a5b184..c6afb92c 100644 --- a/tests/test_poller.cpp +++ b/tests/test_poller.cpp @@ -30,7 +30,6 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include #include #ifndef _WIN32 @@ -40,15 +39,7 @@ #include #endif -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT fd_t get_fd (void *socket_) { diff --git a/tests/test_probe_router.cpp b/tests/test_probe_router.cpp index aa31f52a..14e68e31 100644 --- a/tests/test_probe_router.cpp +++ b/tests/test_probe_router.cpp @@ -30,15 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_probe_router_router () { diff --git a/tests/test_proxy.cpp b/tests/test_proxy.cpp index d4010e5e..214fac7e 100644 --- a/tests/test_proxy.cpp +++ b/tests/test_proxy.cpp @@ -33,15 +33,7 @@ #include #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT #define CONTENT_SIZE 13 #define CONTENT_SIZE_MAX 32 diff --git a/tests/test_proxy_single_socket.cpp b/tests/test_proxy_single_socket.cpp index 31a9adf0..de8e445e 100644 --- a/tests/test_proxy_single_socket.cpp +++ b/tests/test_proxy_single_socket.cpp @@ -32,15 +32,7 @@ #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT // This is our server task. // It runs a proxy with a single REP socket as both frontend and backend. diff --git a/tests/test_proxy_terminate.cpp b/tests/test_proxy_terminate.cpp index 215eb384..76cd852b 100644 --- a/tests/test_proxy_terminate.cpp +++ b/tests/test_proxy_terminate.cpp @@ -32,15 +32,7 @@ #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT // This is a test for issue #1382. The server thread creates a SUB-PUSH // steerable proxy. The main process then sends messages to the SUB diff --git a/tests/test_pub_invert_matching.cpp b/tests/test_pub_invert_matching.cpp index 330bbb03..4a5b3f5d 100644 --- a/tests/test_pub_invert_matching.cpp +++ b/tests/test_pub_invert_matching.cpp @@ -32,15 +32,7 @@ #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test () { diff --git a/tests/test_radio_dish.cpp b/tests/test_radio_dish.cpp index 6a7c1476..447b42a5 100644 --- a/tests/test_radio_dish.cpp +++ b/tests/test_radio_dish.cpp @@ -30,8 +30,6 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - #include #ifndef _WIN32 @@ -53,15 +51,7 @@ _test (true); \ } -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void msg_send_expect_success (void *s_, const char *group_, const char *body_) { diff --git a/tests/test_rebind_ipc.cpp b/tests/test_rebind_ipc.cpp index 55512c77..41830c95 100644 --- a/tests/test_rebind_ipc.cpp +++ b/tests/test_rebind_ipc.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_rebind_ipc () { diff --git a/tests/test_reconnect_ivl.cpp b/tests/test_reconnect_ivl.cpp index 5d225398..ca4f15ed 100644 --- a/tests/test_reconnect_ivl.cpp +++ b/tests/test_reconnect_ivl.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_reconnect_ivl_against_pair_socket (const char *my_endpoint_, void *sb_) diff --git a/tests/test_req_correlate.cpp b/tests/test_req_correlate.cpp index 1f801625..03a17ed8 100644 --- a/tests/test_req_correlate.cpp +++ b/tests/test_req_correlate.cpp @@ -30,15 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_req_correlate () { diff --git a/tests/test_reqrep_device.cpp b/tests/test_reqrep_device.cpp index 45c15b1b..3b7b2070 100644 --- a/tests/test_reqrep_device.cpp +++ b/tests/test_reqrep_device.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_roundtrip () { diff --git a/tests/test_reqrep_device_tipc.cpp b/tests/test_reqrep_device_tipc.cpp index 70d540fe..930c9dad 100644 --- a/tests/test_reqrep_device_tipc.cpp +++ b/tests/test_reqrep_device_tipc.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT // TODO this is heavily duplicated with test_reqrep_device.cpp void test_roundtrip () diff --git a/tests/test_reqrep_inproc.cpp b/tests/test_reqrep_inproc.cpp index 83d6f24b..d12d67e0 100644 --- a/tests/test_reqrep_inproc.cpp +++ b/tests/test_reqrep_inproc.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_roundtrip () { diff --git a/tests/test_reqrep_ipc.cpp b/tests/test_reqrep_ipc.cpp index d488c470..090c5c56 100644 --- a/tests/test_reqrep_ipc.cpp +++ b/tests/test_reqrep_ipc.cpp @@ -31,17 +31,8 @@ #include "testutil_unity.hpp" #include -#include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_leak () { diff --git a/tests/test_reqrep_tcp.cpp b/tests/test_reqrep_tcp.cpp index 71da2c3d..c1bdf471 100644 --- a/tests/test_reqrep_tcp.cpp +++ b/tests/test_reqrep_tcp.cpp @@ -32,15 +32,7 @@ #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_single_connect (int ipv6_) { diff --git a/tests/test_reqrep_tipc.cpp b/tests/test_reqrep_tipc.cpp index 46aa25ee..c4b64c8f 100644 --- a/tests/test_reqrep_tipc.cpp +++ b/tests/test_reqrep_tipc.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_roundtrip () { diff --git a/tests/test_reqrep_vmci.cpp b/tests/test_reqrep_vmci.cpp index 09970eae..0672f68d 100644 --- a/tests/test_reqrep_vmci.cpp +++ b/tests/test_reqrep_vmci.cpp @@ -34,15 +34,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_reqrep_vmci () { diff --git a/tests/test_router_handover.cpp b/tests/test_router_handover.cpp index e04bcf6e..c43fc587 100644 --- a/tests/test_router_handover.cpp +++ b/tests/test_router_handover.cpp @@ -28,20 +28,9 @@ */ #include "testutil.hpp" - #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_with_handover () { diff --git a/tests/test_router_mandatory.cpp b/tests/test_router_mandatory.cpp index 7bfd0d8d..ec8b8314 100644 --- a/tests/test_router_mandatory.cpp +++ b/tests/test_router_mandatory.cpp @@ -31,17 +31,8 @@ #include "testutil_unity.hpp" #include -#include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT #ifdef ZMQ_BUILD_DRAFT_API bool send_msg_to_peer_if_ready (void *router_, const char *peer_routing_id_) diff --git a/tests/test_router_mandatory_hwm.cpp b/tests/test_router_mandatory_hwm.cpp index 1cf4d72d..870365b3 100644 --- a/tests/test_router_mandatory_hwm.cpp +++ b/tests/test_router_mandatory_hwm.cpp @@ -30,15 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT // DEBUG shouldn't be defined in sources as it will cause a redefined symbol // error when it is defined in the build configuration. It appears that the diff --git a/tests/test_router_mandatory_tipc.cpp b/tests/test_router_mandatory_tipc.cpp index 5a3877e3..af9b2568 100644 --- a/tests/test_router_mandatory_tipc.cpp +++ b/tests/test_router_mandatory_tipc.cpp @@ -32,15 +32,7 @@ #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_router_mandatory_tipc () { diff --git a/tests/test_router_notify.cpp b/tests/test_router_notify.cpp index a388fd55..2256018a 100644 --- a/tests/test_router_notify.cpp +++ b/tests/test_router_notify.cpp @@ -31,17 +31,8 @@ #include "testutil_unity.hpp" #include -#include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_sockopt_router_notify () { diff --git a/tests/test_scatter_gather.cpp b/tests/test_scatter_gather.cpp index f6ee3647..79465bc0 100644 --- a/tests/test_scatter_gather.cpp +++ b/tests/test_scatter_gather.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_scatter_gather_multipart_fails () { diff --git a/tests/test_security_no_zap_handler.cpp b/tests/test_security_no_zap_handler.cpp index 70b05955..cce2ef66 100644 --- a/tests/test_security_no_zap_handler.cpp +++ b/tests/test_security_no_zap_handler.cpp @@ -30,15 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_no_zap_handler () { diff --git a/tests/test_security_zap.cpp b/tests/test_security_zap.cpp index b679733d..d76a1c24 100644 --- a/tests/test_security_zap.cpp +++ b/tests/test_security_zap.cpp @@ -30,15 +30,7 @@ #include "testutil_security.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT static void zap_handler_wrong_version (void * /*unused_*/) { diff --git a/tests/test_setsockopt.cpp b/tests/test_setsockopt.cpp index 29c48a77..b2edfb9e 100644 --- a/tests/test_setsockopt.cpp +++ b/tests/test_setsockopt.cpp @@ -32,15 +32,7 @@ #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_setsockopt_tcp_recv_buffer () { diff --git a/tests/test_sockopt_hwm.cpp b/tests/test_sockopt_hwm.cpp index 129fd13e..d96118e3 100644 --- a/tests/test_sockopt_hwm.cpp +++ b/tests/test_sockopt_hwm.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT const int MAX_SENDS = 10000; diff --git a/tests/test_spec_dealer.cpp b/tests/test_spec_dealer.cpp index 6a857784..8b9aeb7f 100644 --- a/tests/test_spec_dealer.cpp +++ b/tests/test_spec_dealer.cpp @@ -30,16 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} - +SETUP_TEARDOWN_TESTCONTEXT // SHALL route outgoing messages to available peers using a round-robin // strategy. diff --git a/tests/test_spec_pushpull.cpp b/tests/test_spec_pushpull.cpp index 3ae16a1a..d3602088 100644 --- a/tests/test_spec_pushpull.cpp +++ b/tests/test_spec_pushpull.cpp @@ -33,15 +33,7 @@ #include #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT char connect_address[MAX_SOCKET_STRING]; diff --git a/tests/test_spec_rep.cpp b/tests/test_spec_rep.cpp index 816e0dbf..2e47d530 100644 --- a/tests/test_spec_rep.cpp +++ b/tests/test_spec_rep.cpp @@ -31,17 +31,8 @@ #include "testutil_unity.hpp" #include -#include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT char connect_address[MAX_SOCKET_STRING]; diff --git a/tests/test_spec_req.cpp b/tests/test_spec_req.cpp index 13029b18..6df0de81 100644 --- a/tests/test_spec_req.cpp +++ b/tests/test_spec_req.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT char connect_address[MAX_SOCKET_STRING]; diff --git a/tests/test_spec_router.cpp b/tests/test_spec_router.cpp index 87c7610c..dc170de3 100644 --- a/tests/test_spec_router.cpp +++ b/tests/test_spec_router.cpp @@ -32,18 +32,8 @@ #include #include -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT // SHALL receive incoming messages from its peers using a fair-queuing // strategy. diff --git a/tests/test_srcfd.cpp b/tests/test_srcfd.cpp index ae855f27..e0c08d19 100644 --- a/tests/test_srcfd.cpp +++ b/tests/test_srcfd.cpp @@ -31,17 +31,8 @@ #include "testutil_unity.hpp" #include -#include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT #define MSG_SIZE 20 diff --git a/tests/test_stream.cpp b/tests/test_stream.cpp index cc16b8e5..b842b7f4 100644 --- a/tests/test_stream.cpp +++ b/tests/test_stream.cpp @@ -32,15 +32,7 @@ #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT // ZMTP protocol greeting structure diff --git a/tests/test_stream_disconnect.cpp b/tests/test_stream_disconnect.cpp index 6859dc8b..d9865282 100644 --- a/tests/test_stream_disconnect.cpp +++ b/tests/test_stream_disconnect.cpp @@ -32,15 +32,7 @@ #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT static const int SERVER = 0; static const int CLIENT = 1; diff --git a/tests/test_stream_empty.cpp b/tests/test_stream_empty.cpp index bdee1011..dd4c2c6a 100644 --- a/tests/test_stream_empty.cpp +++ b/tests/test_stream_empty.cpp @@ -30,15 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_stream_empty () { diff --git a/tests/test_stream_exceeds_buffer.cpp b/tests/test_stream_exceeds_buffer.cpp index e3ef19d9..767946d7 100644 --- a/tests/test_stream_exceeds_buffer.cpp +++ b/tests/test_stream_exceeds_buffer.cpp @@ -38,15 +38,7 @@ #include #endif -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_stream_exceeds_buffer () { diff --git a/tests/test_stream_timeout.cpp b/tests/test_stream_timeout.cpp index 41cab0c6..5364298e 100644 --- a/tests/test_stream_timeout.cpp +++ b/tests/test_stream_timeout.cpp @@ -33,15 +33,7 @@ #include #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT // Read one event off the monitor socket; return value and address // by reference, if not null, and event number by value. Returns -1 diff --git a/tests/test_sub_forward.cpp b/tests/test_sub_forward.cpp index ab425609..c5a9865c 100644 --- a/tests/test_sub_forward.cpp +++ b/tests/test_sub_forward.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test () { diff --git a/tests/test_sub_forward_tipc.cpp b/tests/test_sub_forward_tipc.cpp index 2c59e734..949c0d1e 100644 --- a/tests/test_sub_forward_tipc.cpp +++ b/tests/test_sub_forward_tipc.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test () { diff --git a/tests/test_system.cpp b/tests/test_system.cpp index 9c8024ad..41d37358 100644 --- a/tests/test_system.cpp +++ b/tests/test_system.cpp @@ -39,15 +39,7 @@ #include #endif -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT // Solaris has a default of 256 max files per process #ifdef ZMQ_HAVE_SOLARIS diff --git a/tests/test_term_endpoint.cpp b/tests/test_term_endpoint.cpp index fe97c346..8f1a9e24 100644 --- a/tests/test_term_endpoint.cpp +++ b/tests/test_term_endpoint.cpp @@ -30,15 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT /* Use the worst case filename size for the buffer (+1 for trailing NUL), this * is larger than MAX_SOCKET_STRING, which is not large enough for IPC */ diff --git a/tests/test_term_endpoint_tipc.cpp b/tests/test_term_endpoint_tipc.cpp index 8ab763a7..7562b0d5 100644 --- a/tests/test_term_endpoint_tipc.cpp +++ b/tests/test_term_endpoint_tipc.cpp @@ -30,15 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT const char ep[] = "tipc://{5560,0,0}"; const char name[] = "tipc://{5560,0}@0.0.0"; diff --git a/tests/test_thread_safe.cpp b/tests/test_thread_safe.cpp index 5960c4b7..99451dff 100644 --- a/tests/test_thread_safe.cpp +++ b/tests/test_thread_safe.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT // Client threads loop on send/recv until told to exit void client_thread (void *client_) diff --git a/tests/test_timeo.cpp b/tests/test_timeo.cpp index 9e0c07f3..5de316f1 100644 --- a/tests/test_timeo.cpp +++ b/tests/test_timeo.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_timeo () { diff --git a/tests/test_unbind_wildcard.cpp b/tests/test_unbind_wildcard.cpp index 8d09fd5f..f25d6acc 100644 --- a/tests/test_unbind_wildcard.cpp +++ b/tests/test_unbind_wildcard.cpp @@ -22,15 +22,7 @@ #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_address_wildcard_ipv4 () { diff --git a/tests/test_use_fd.cpp b/tests/test_use_fd.cpp index 49e2e0f2..86d9c328 100644 --- a/tests/test_use_fd.cpp +++ b/tests/test_use_fd.cpp @@ -32,19 +32,9 @@ #include #include -#include #include -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} - +SETUP_TEARDOWN_TESTCONTEXT #if !defined(ZMQ_HAVE_WINDOWS) #include diff --git a/tests/test_xpub_manual.cpp b/tests/test_xpub_manual.cpp index 5acee591..cbefc154 100644 --- a/tests/test_xpub_manual.cpp +++ b/tests/test_xpub_manual.cpp @@ -30,15 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_basic () { diff --git a/tests/test_xpub_nodrop.cpp b/tests/test_xpub_nodrop.cpp index 6eb5dbb3..8df8486a 100644 --- a/tests/test_xpub_nodrop.cpp +++ b/tests/test_xpub_nodrop.cpp @@ -30,15 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test () { diff --git a/tests/test_xpub_verbose.cpp b/tests/test_xpub_verbose.cpp index 9532a32a..258c5674 100644 --- a/tests/test_xpub_verbose.cpp +++ b/tests/test_xpub_verbose.cpp @@ -30,15 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT const uint8_t unsubscribe_a_msg[] = {0, 'A'}; const uint8_t subscribe_a_msg[] = {1, 'A'}; diff --git a/tests/test_xpub_welcome_msg.cpp b/tests/test_xpub_welcome_msg.cpp index ad6bdae7..0066d9ff 100644 --- a/tests/test_xpub_welcome_msg.cpp +++ b/tests/test_xpub_welcome_msg.cpp @@ -30,17 +30,7 @@ #include "testutil.hpp" #include "testutil_unity.hpp" -#include - -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test () { diff --git a/tests/test_zmq_poll_fd.cpp b/tests/test_zmq_poll_fd.cpp index 4df49c56..e155310f 100644 --- a/tests/test_zmq_poll_fd.cpp +++ b/tests/test_zmq_poll_fd.cpp @@ -32,21 +32,12 @@ #include #include -#include #ifndef _WIN32 #include #endif -void setUp () -{ - setup_test_context (); -} - -void tearDown () -{ - teardown_test_context (); -} +SETUP_TEARDOWN_TESTCONTEXT void test_poll_fd () { diff --git a/tests/testutil_unity.hpp b/tests/testutil_unity.hpp index 4cedb249..4bf8b4b2 100644 --- a/tests/testutil_unity.hpp +++ b/tests/testutil_unity.hpp @@ -181,6 +181,12 @@ void recv_array_expect_success (void *socket_, // for each test case, and some consistency checks can be performed. ///////////////////////////////////////////////////////////////////////////// +// Use this is an test executable to perform a default setup and teardown of +// the test context, which is appropriate for many libzmq test cases. +#define SETUP_TEARDOWN_TESTCONTEXT \ + void setUp () { setup_test_context (); } \ + void tearDown () { teardown_test_context (); } + // The maximum number of sockets that can be managed by the test context. #define MAX_TEST_SOCKETS 128