• Patrik Wenger's avatar
    Problem: tricky return value from zmq::socket_poller_t::wait when poller is empty · 621c965f
    Patrik Wenger authored
    Solution: return -1 (no event) instead of 0 (event)
    
    For some reason, this just returns 0 if there are no sockets registered
    on the poller. Usually this would mean there has been an event. So the
    caller would have to check the return value AND the event, or write code
    that takes the number of registered sockets into consideration.
    
    By returning -1 and setting errno = ETIMEDOUT like in the usual timeout
    cases, it's more consistent and convenient.
    
    Test case included.
    621c965f
Name
Last commit
Last update
..
CMakeLists.txt Problem: test_large_msg requires 2GB of free RAM
README.md Problem: Tests do no build in Windows environment
test_abstract_ipc.cpp Problem: copyright year is still 2015
test_atomics.cpp Problem: copyright year is still 2015
test_bind_src_address.cpp Problem: copyright year is still 2015
test_capabilities.cpp Problem: use of libsodium vs. tweetnacl is confused
test_client_server.cpp Problem: copyright year is still 2015
test_conflate.cpp Revert "Revert "Problem: deprecated use and reference of `zmq_term`""
test_connect_delay_tipc.cpp Problem: tests don't build on Windows
test_connect_resolve.cpp Problem: copyright year is still 2015
test_connect_rid.cpp Problem: copyright year is still 2015
test_ctx_destroy.cpp Problem: copyright year is still 2015
test_ctx_options.cpp Problem: copyright year is still 2015
test_diffserv.cpp Problem: copyright year is still 2015
test_disconnect_inproc.cpp Problem: copyright year is still 2015
test_filter_ipc.cpp Problem: tests don't build on Windows
test_fork.cpp Problem: test_fork does not clean up at exit
test_getsockopt_memset.cpp Problem: copyright year is still 2015
test_heartbeats.cpp Problem: tests use various sleep patterns to wait
test_hwm.cpp Problem: copyright year is still 2015
test_hwm_pubsub.cpp Problem: tests use various sleep patterns to wait
test_immediate.cpp Problem: various tests fail in slow environments
test_inproc_connect.cpp Problem: copyright year is still 2015
test_invalid_rep.cpp Problem: copyright year is still 2015
test_iov.cpp Problem: copyright year is still 2015
test_ipc_wildcard.cpp Problem: copyright year is still 2015
test_issue_566.cpp Problem: copyright year is still 2015
test_last_endpoint.cpp Problem: copyright year is still 2015
test_many_sockets.cpp Fix tests/test_many_sockets.cpp
test_metadata.cpp Problem: copyright year is still 2015
test_monitor.cpp Problem: copyright year is still 2015
test_msg_ffn.cpp Problem: tests use various sleep patterns to wait
test_msg_flags.cpp Problem: copyright year is still 2015
test_pair_inproc.cpp Problem: copyright year is still 2015
test_pair_ipc.cpp Problem: copyright year is still 2015
test_pair_tcp.cpp Problem: copyright year is still 2015
test_pair_tipc.cpp Problem: tests don't build on Windows
test_pair_vmci.cpp Problem: copyright year is still 2015
test_poller.cpp Problem: tricky return value from zmq::socket_poller_t::wait when poller is empty
test_probe_router.cpp Problem: copyright year is still 2015
test_proxy.cpp Problem: deprecated `zmq_utils.h` is still included
test_proxy_single_socket.cpp Problem: deprecated `zmq_utils.h` is still included
test_proxy_terminate.cpp Problem: tests use various sleep patterns to wait
test_pub_invert_matching.cpp Problem: copyright year is still 2015
test_radio_dish.cpp Problem: tests use various sleep patterns to wait
test_req_correlate.cpp Fixed ZMQ_REQ_CORRELATE (see pull request #1730)
test_req_relaxed.cpp Fixed ZMQ_REQ_CORRELATE (see pull request #1730)
test_reqrep_device.cpp Problem: copyright year is still 2015
test_reqrep_device_tipc.cpp Problem: tests don't build on Windows
test_reqrep_inproc.cpp Problem: copyright year is still 2015
test_reqrep_ipc.cpp Loading commit data...
test_reqrep_tcp.cpp Loading commit data...
test_reqrep_tipc.cpp Loading commit data...
test_reqrep_vmci.cpp Loading commit data...
test_router_handover.cpp Loading commit data...
test_router_mandatory.cpp Loading commit data...
test_router_mandatory_hwm.cpp Loading commit data...
test_router_mandatory_tipc.cpp Loading commit data...
test_security_curve.cpp Loading commit data...
test_security_null.cpp Loading commit data...
test_security_plain.cpp Loading commit data...
test_setsockopt.cpp Loading commit data...
test_shutdown_stress.cpp Loading commit data...
test_shutdown_stress_tipc.cpp Loading commit data...
test_sockopt_hwm.cpp Loading commit data...
test_spec_dealer.cpp Loading commit data...
test_spec_pushpull.cpp Loading commit data...
test_spec_rep.cpp Loading commit data...
test_spec_req.cpp Loading commit data...
test_spec_router.cpp Loading commit data...
test_srcfd.cpp Loading commit data...
test_stream.cpp Loading commit data...
test_stream_disconnect.cpp Loading commit data...
test_stream_empty.cpp Loading commit data...
test_stream_exceeds_buffer.cpp Loading commit data...
test_stream_timeout.cpp Loading commit data...
test_sub_forward.cpp Loading commit data...
test_sub_forward_tipc.cpp Loading commit data...
test_system.cpp Loading commit data...
test_term_endpoint.cpp Loading commit data...
test_term_endpoint_tipc.cpp Loading commit data...
test_thread_safe.cpp Loading commit data...
test_timeo.cpp Loading commit data...
test_timers.cpp Loading commit data...
test_udp.cpp Loading commit data...
test_unbind_inproc.cpp Loading commit data...
test_unbind_wildcard.cpp Loading commit data...
test_use_fd_ipc.cpp Loading commit data...
test_use_fd_tcp.cpp Loading commit data...
test_xpub_manual.cpp Loading commit data...
test_xpub_nodrop.cpp Loading commit data...
test_xpub_welcome_msg.cpp Loading commit data...
testutil.hpp Loading commit data...

Guidelines for tests

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

The only include file you should use is testutil.hpp. Do not include files from src. Do not use the internal libzmq API or your test case is fair game to be deleted.

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 header. Please copy from test_system.cpp if you're not certain.

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, test 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);

Building tests in Windows

Install CMAKE CMD> CMAKE libzmq/tests CMD> tests.sln CMD> # build all projects in the solution