libzmq/tests
Luca Boccassi 22c3ecc458 Problem: some context options have no getter
Solution: add one so that class-based bindings can easily use them
2018-11-18 13:23:38 +00:00
..
CMakeLists.txt Hwm tests and docs (#3242) 2018-09-13 22:14:06 +01:00
README.md Problem: missing guidelines on proper test cleanup 2018-03-14 12:26:06 +01:00
test_abstract_ipc.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_address_tipc.cpp Support application metadata through ZMQ_METADATA 2018-03-14 12:56:15 +01:00
test_ancillaries.cpp Problem: test_ancillarries not yet using unity 2018-08-22 11:51:09 +02:00
test_app_meta.cpp Problem: test_app_meta cannot be ran in parallel 2018-11-09 16:46:48 +00:00
test_atomics.cpp Problem: copyright year is still 2015 2016-01-28 15:07:31 +01: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 Migrate tests/test_bind_after_connect_tcp.cpp to unity 2018-03-14 18:45:25 +01:00
test_bind_src_address.cpp Migrate tests/test_bind_src_address.cpp to unity 2018-03-14 18:45:25 +01:00
test_capabilities.cpp Problem: test_capabilities not yet using unity 2018-08-22 11:51:09 +02:00
test_client_server.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_conflate.cpp Migrate tests/test_conflate.cpp to unity 2018-03-14 19:05:19 +01:00
test_connect_delay_tipc.cpp Problem: test_connect_delay_tipc randomly fails 2018-09-29 22:39:36 +01: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: test_connect_rid not yet using unity 2018-08-17 10:19:00 +02:00
test_ctx_destroy.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_ctx_options.cpp Problem: some context options have no getter 2018-11-18 13:23:38 +00:00
test_dgram.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_diffserv.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_disconnect_inproc.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_filter_ipc.cpp Problem: typo in RUN_TEST macro breaks debian/kfreebsd build 2018-11-04 18:12:18 +00:00
test_fork.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_getsockopt_memset.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_heartbeats.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_hwm_pubsub.cpp Problem: GNU/Hurd does not implement getsockname for ipc 2018-11-05 10:59:12 +00:00
test_hwm.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_immediate.cpp Problem: test_immediate not using unity 2018-03-16 15:46:39 +01:00
test_inproc_connect.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_invalid_rep.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_iov.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_ipc_wildcard.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_issue_566.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_last_endpoint.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_many_sockets.cpp Problem: test_many_sockets does not show number of sockets that could be created 2018-05-23 16:25:08 +02:00
test_metadata.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_mock_pub_sub.cpp Problem: can't process ZMTP 3.1 cancel/subscribe commands 2018-06-23 17:16:10 +01:00
test_monitor.cpp Problem: new DRAFT monitoring events are eligible for STABLE 2018-11-18 13:23:38 +00:00
test_msg_ffn.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_msg_flags.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_pair_inproc.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_pair_ipc.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_pair_tcp.cpp Problem: test_pair_tcp not yet using unity 2018-08-20 11:13:12 +02:00
test_pair_tipc.cpp Problem: TIPC availability check is too strict (#2977) 2018-03-09 17:47:42 +01:00
test_pair_vmci.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_poller.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_probe_router.cpp Problem: test case test_probe_router_router does not receive auto-generated routing id 2018-08-13 13:26:50 +02:00
test_proxy_hwm.cpp Problem: test_proxy_hwm expects wrong number of msgs 2018-09-16 21:20:10 +01:00
test_proxy_single_socket.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_proxy_terminate.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_proxy.cpp Revert "Problem: test_proxy not yet using unity" 2018-08-24 09:49:41 +02:00
test_pub_invert_matching.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_radio_dish.cpp Problem: test cases setting ZMQ_MULTICAST_LOOP to false fail on Windows 2018-05-23 16:26:52 +02:00
test_rebind_ipc.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_reconnect_ivl.cpp Problem: GNU/Hurd does not implement getsockname for ipc 2018-11-05 10:59:12 +00:00
test_req_correlate.cpp Problem: test_req_correlate not yet using unity 2018-08-22 11:51:09 +02:00
test_req_relaxed.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_reqrep_device_tipc.cpp Problem: TIPC availability check is too strict (#2977) 2018-03-09 17:47:42 +01:00
test_reqrep_device.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_reqrep_inproc.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_reqrep_ipc.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_reqrep_tcp.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_reqrep_tipc.cpp Problem: TIPC availability check is too strict (#2977) 2018-03-09 17:47:42 +01:00
test_reqrep_vmci.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_router_handover.cpp Problem: inconsistent _out_pipes when using the same routing id without ZMQ_ROUTER_HANDOVER 2018-08-17 12:50:59 +02:00
test_router_mandatory_hwm.cpp Problem: test_router_mandatory_hwm not yet using unity 2018-08-23 18:00:51 +02:00
test_router_mandatory_tipc.cpp Problem: TIPC availability check is too strict (#2977) 2018-03-09 17:47:42 +01:00
test_router_mandatory.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_router_notify.cpp Problem: test_router_notify cannot be ran in parallel 2018-11-09 16:56:00 +00:00
test_scatter_gather.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_security_curve.cpp Problem: new DRAFT monitoring events are eligible for STABLE 2018-11-18 13:23:38 +00:00
test_security_gssapi.cpp Problem: new DRAFT monitoring events are eligible for STABLE 2018-11-18 13:23:38 +00:00
test_security_null.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_security_plain.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_security_zap.cpp Problem: new DRAFT monitoring events are eligible for STABLE 2018-11-18 13:23:38 +00:00
test_setsockopt.cpp Problem: test_setsockopt not yet using unity 2018-08-17 10:19:00 +02:00
test_shutdown_stress_tipc.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_shutdown_stress.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02: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: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_sodium.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_spec_dealer.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_spec_pushpull.cpp Problem: test_spec_pushpull not yet using unity 2018-08-22 11:51:09 +02:00
test_spec_rep.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_spec_req.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_spec_router.cpp Problem: test_spec_router not yet using unity 2018-08-17 10:19:00 +02:00
test_srcfd.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_stream_disconnect.cpp Problem: test_stream_disconnect not yet using unity 2018-08-23 18:00:51 +02:00
test_stream_empty.cpp Problem: test_stream_empty not yet using unity 2018-08-22 11:51:10 +02:00
test_stream_exceeds_buffer.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_stream_timeout.cpp Problem: test_stream_timeout not yet using unity 2018-08-23 18:00:51 +02:00
test_stream.cpp Problem: test_stream not yet using unity 2018-08-22 11:51:10 +02:00
test_sub_forward_tipc.cpp Problem: TIPC availability check is too strict (#2977) 2018-03-09 17:47:42 +01:00
test_sub_forward.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_system.cpp Problem: C4244 warnings regarding SOCKET vs. int in test_system 2018-05-14 21:09:57 +02:00
test_term_endpoint_tipc.cpp Problem: TIPC availability check is too strict (#2977) 2018-03-09 17:47:42 +01:00
test_term_endpoint.cpp Problem: test_term_endpoint not yet using unity 2018-08-17 10:19:00 +02:00
test_thread_safe.cpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +02:00
test_timeo.cpp Problem: test_timeo frequently fails on travis, probably because of slow 2018-02-09 09:56:38 +01:00
test_timers.cpp Problem: test_timers not yet using unity 2018-08-23 18:00:51 +02:00
test_unbind_wildcard.cpp Problem: test_unbind_wildcard not yet using unity 2018-08-22 11:51:10 +02:00
test_use_fd.cpp Problem: test_use_fd not yet using unity 2018-08-23 18:03:16 +02:00
test_xpub_manual.cpp Problem: test_xpub_manual not yet using unity 2018-08-22 11:51:10 +02:00
test_xpub_nodrop.cpp Problem: test_xpub_nodrop not using test framework 2018-05-22 18:33:18 +02:00
test_xpub_verbose.cpp Problem: test_xpub_verbose is not using testutil_unity 2018-08-22 11:51:11 +02:00
test_xpub_welcome_msg.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
test_zmq_poll_fd.cpp Problem: formatting inconsistent 2018-02-02 15:47:43 +01:00
testutil_security.hpp Problem: new DRAFT monitoring events are eligible for STABLE 2018-11-18 13:23:38 +00:00
testutil_unity.hpp Problem: test_xpub_manual not yet using unity 2018-08-22 11:51:10 +02:00
testutil.hpp Problem: tests do not follow naming style 2018-05-27 13:24:08 +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.