libzmq/tests
Luca Boccassi eec972a5b4 Problem: unused variable in test tool
Solution: don't write it
2019-07-09 18:10:25 +01:00
..
CMakeLists.txt Support XPub socket send last value caching to last subscription pipe with ZMQ_XPUB_MANUAL_LAST_VALUE. (#3511) 2019-05-17 22:12:32 +01:00
README.md Problem: missing guidelines on proper test cleanup 2018-03-14 12:26:06 +01:00
test_abstract_ipc.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_address_tipc.cpp Problem: test_address_tipc is unnecessarily verbose 2019-03-24 13:34:13 -04:00
test_ancillaries.cpp Problem: remaining basic assertions 2019-03-23 09:09:36 -04:00
test_app_meta.cpp Problem: test_bind used with explicit endpoint where bind_loopback_ipv4 could be used 2019-03-24 12:35:19 -04:00
test_atomics.cpp Problem: tests without test framework 2018-12-09 07:36:39 -05:00
test_base85.cpp Problem: test_base85 not yet using unity 2018-08-22 11:51:08 +02:00
test_bind_after_connect_tcp.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_bind_src_address.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_capabilities.cpp Problem: test_capabilities not yet using unity 2018-08-22 11:51:09 +02:00
test_client_server.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_conflate.cpp Problem: code from bind_loopback_ipv4 is duplicated 2019-03-24 13:34:13 -04:00
test_connect_delay_tipc.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_connect_resolve.cpp Problem: test_connect_resolve not yet using unity 2018-03-14 22:40:24 +01:00
test_connect_rid.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_ctx_destroy.cpp Problem: remaining basic assertions 2019-03-23 09:09:36 -04:00
test_ctx_options.cpp Problem: code from bind_loopback_ipv4 is duplicated 2019-03-24 13:34:13 -04:00
test_dgram.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_diffserv.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_disconnect_inproc.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_filter_ipc.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_fork.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_getsockopt_memset.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_heartbeats.cpp Problem: missing heartbeat test for draft sockets 2019-06-23 13:23:21 -04:00
test_hwm_pubsub.cpp Merge pull request #3467 from sigiesec/improve-hwm-pubsub-test 2019-04-02 19:44:55 +01:00
test_hwm.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_immediate.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_inproc_connect.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_invalid_rep.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_iov.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_ipc_wildcard.cpp Problem: code from bind_loopback_ipc is duplicated 2019-03-24 13:34:13 -04:00
test_issue_566.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_last_endpoint.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_many_sockets.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_metadata.cpp Problem: s_send(more) can be replaced by safer send_string_expect_success 2019-03-24 13:34:13 -04:00
test_mock_pub_sub.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_monitor.cpp Problem: zmq_socket_monitor_versioned_typed duplicates zmq_socket_monitor_versioned 2019-05-18 16:44:07 +01:00
test_msg_ffn.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_msg_flags.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_pair_inproc.cpp Problem: tests without test framework 2018-12-10 07:01:06 -05:00
test_pair_ipc.cpp Problem: code from bind_loopback_ipc is duplicated 2019-03-24 13:34:13 -04:00
test_pair_tcp_cap_net_admin.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_pair_tcp.cpp Problem: socket returned by ZMQ_FD cannot be used with CreateIoCompletionPort 2019-03-27 09:56:11 +01:00
test_pair_tipc.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_pair_vmci.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_poller.cpp Problem: signature of zmq_poller_fd does is incompatible with regular error handling 2019-05-09 11:09:35 -04:00
test_probe_router.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_proxy_hwm.cpp Problem: unused include directives 2019-03-23 09:46:37 -04:00
test_proxy_single_socket.cpp Problem: s_send(more) can be replaced by safer send_string_expect_success 2019-03-24 13:34:13 -04:00
test_proxy_terminate.cpp Problem: s_send(more) can be replaced by safer send_string_expect_success 2019-03-24 13:34:13 -04:00
test_proxy.cpp Problem: s_send(more) can be replaced by safer send_string_expect_success 2019-03-24 13:34:13 -04:00
test_pub_invert_matching.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_radio_dish.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_rebind_ipc.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_reconnect_ivl.cpp Problem: code from bind_loopback_ipv4 is duplicated 2019-03-24 13:34:13 -04:00
test_req_correlate.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_req_relaxed.cpp Problem: tests without test framework 2018-12-10 07:01:06 -05:00
test_reqrep_device_tipc.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_reqrep_device.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_reqrep_inproc.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_reqrep_ipc.cpp Problem: code from bind_loopback_ipc is duplicated 2019-03-24 13:34:13 -04:00
test_reqrep_tcp.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_reqrep_tipc.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_reqrep_vmci.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_router_handover.cpp Problem: code from bind_loopback_ipv4 is duplicated 2019-03-24 13:34:13 -04:00
test_router_mandatory_hwm.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_router_mandatory_tipc.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_router_mandatory.cpp Problem: code from bind_loopback_ipv4 is duplicated 2019-03-24 13:34:13 -04:00
test_router_notify.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_scatter_gather.cpp Problem: s_send(more) can be replaced by safer send_string_expect_success 2019-03-24 13:34:13 -04:00
test_security_curve.cpp Implement thread name on windows, cleanup thread naming internals 2019-05-21 12:12:19 +02:00
test_security_gssapi.cpp Problem: s_send(more) can be replaced by safer send_string_expect_success 2019-03-24 13:34:13 -04:00
test_security_no_zap_handler.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_security_null.cpp Problem: s_send(more) can be replaced by safer send_string_expect_success 2019-03-24 13:34:13 -04:00
test_security_plain.cpp Problem: s_send(more) can be replaced by safer send_string_expect_success 2019-03-24 13:34:13 -04:00
test_security_zap.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_setsockopt.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_shutdown_stress_tipc.cpp Problem: unused include directives 2019-03-23 09:46:37 -04:00
test_shutdown_stress.cpp Problem: tests without test framework 2018-12-16 12:28:42 -05:00
test_socket_null.cpp Problem: test_socket_null not using test framework 2018-02-11 17:25:36 +00:00
test_sockopt_hwm.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_socks.cpp Add tests for SOCKS proxy support 2019-06-13 15:35:27 +02:00
test_sodium.cpp Problem: tests without test framework 2018-12-16 12:28:42 -05:00
test_spec_dealer.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_spec_pushpull.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_spec_rep.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_spec_req.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_spec_router.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_srcfd.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_stream_disconnect.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_stream_empty.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_stream_exceeds_buffer.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_stream_timeout.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_stream.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_sub_forward_tipc.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_sub_forward.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_system.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_term_endpoint_tipc.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_term_endpoint.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_thread_safe.cpp Problem: code from bind_loopback_ipv4 is duplicated 2019-03-24 13:34:13 -04:00
test_timeo.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_timers.cpp Problem: zmq_stopwatch_intermediate is eligible for STABLE 2018-11-18 13:23:38 +00:00
test_unbind_wildcard.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_use_fd.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_xpub_manual_last_value.cpp Support XPub socket send last value caching to last subscription pipe with ZMQ_XPUB_MANUAL_LAST_VALUE. (#3511) 2019-05-17 22:12:32 +01:00
test_xpub_manual.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_xpub_nodrop.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_xpub_verbose.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_xpub_welcome_msg.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
test_zmq_poll_fd.cpp Problem: default test setUp/tearDown functions duplicated in many test programs 2019-03-24 12:53:12 -04:00
testutil_monitoring.cpp Problem: unused variable in test tool 2019-07-09 18:10:25 +01:00
testutil_monitoring.hpp Problem: functions are unnecessarily declared in header 2019-03-23 14:09:06 -04:00
testutil_security.cpp Problem: s_send(more) can be replaced by safer send_string_expect_success 2019-03-24 13:34:13 -04:00
testutil_security.hpp Problem: functions are unnecessarily declared in header 2019-03-23 14:09:06 -04:00
testutil_unity.cpp Problem: test assertions not reporting the right line number 2019-06-12 11:20:48 +02:00
testutil_unity.hpp Problem: test assertions not reporting the right line number 2019-06-12 11:20:48 +02:00
testutil.cpp Problem: s_send(more) can be replaced by safer send_string_expect_success 2019-03-24 13:34:13 -04:00
testutil.hpp Implement thread name on windows, cleanup thread naming internals 2019-05-21 12:12:19 +02:00

Guidelines for tests

Write your test case as if you were writing clean application code. It should be safe to compile on all platforms.

Normally, you should only include the header files from the tests directory, e.g. testutil.hpp. Do not include files from src. Do not use the internal libzmq API. Tests for these should be placed in unittests instead.

If you must write non-portable code, wrap it in #ifdefs to ensure it will compile and run on all systems.

Note that testutil.hpp includes platform.h. Do not include it yourself as it changes location depending on the build system and OS.

All sources must contain the correct copyright header. Please copy from test_system.cpp if you're not certain.

Write new tests using the unity test framework. For an example, see test_sockopt_hwm.

Please use only ANSI C99 in test cases, no C++. This is to make the code more reusable.

On many slower environments, like embedded systems, VMs or CI systems, tests might fail because it takes time for sockets to settle after a connect. If you need to add a sleep, please be consistent with all the other tests and use: msleep (SETTLE_TIME);

Ensure proper cleanup

If a test program uses unity, it will execute test cases individually, and will continue to run further test cases if an assertion in one test case fails. However, the test case that had an assertion failure will be aborted. To ensure that the resources of the test case are properly cleaned up, use appropriate setUp and tearDown functions. These are run by unity before each test case starts resp. after it ended (whether successfully or not). The same setUp and tearDown function is used for all test cases in a test program.

For many test cases, the following setUp and tearDown functions will be appropriate: void setUp () { setup_test_context (); }

void tearDown ()
{
	teardown_test_context ();
}

Within the tests, do not use zmq_socket and zmq_close then but test_context_socket and test_context_socket_close instead. These functions will register/unregister sockets with the test_context. All sockets not closed when tearDown is executed, with forcibly be closed with linger=0 before terminating the context. Note that it is a misuse not to close sockets during successful test execution, and a warning will be output.

Building tests in Windows

The tests are only built via cmake, not when using the checked-in Visual Studio .sln files.