Commit Graph

63 Commits

Author SHA1 Message Date
Luca Boccassi
da31917f4f Relicense from LGPL3 + exceptions to Mozilla Public License version 2.0
Relicense permission collected from all relevant authors as tallied at:
https://github.com/rlenferink/libzmq-relicense/blob/master/checklist.md
The relicense grants are collected under RELICENSE/ and will be moved
to the above repository in a later commit.

Fixes https://github.com/zeromq/libzmq/issues/2376
2023-06-05 20:31:47 +01:00
Luca Boccassi
176d72cc9b Problem: build fails with gcc 12
Solution: change test_monitor and example
2022-01-18 16:15:07 +00:00
Simon Giesecke
66094678d1 Problem: intermittent deadlocks/timeouts in test_monitor and test_security_zap
Solution: wait for monitor to stop resp. unregister monitor before
closing monitored socket.
2020-02-04 14:34:36 +01:00
Simon Giesecke
a83c57d0bb Problem: identifiers not conformant with naming convention
Solution: fix identifier names
2019-12-08 15:24:48 +01:00
Luca Boccassi
19ff4d0b6a Problem: zmq_socket_monitor_versioned_typed duplicates zmq_socket_monitor_versioned
Solution: unify the two APIs, as they are both still in DRAFT state and
thus can be changed.
2019-05-18 16:44:07 +01:00
jean-airoldie
8738ada00f Problem: Endpoints are sometimes not unbound quick enough
Solution: Create a unique endpoint for each fcn call.
2019-05-15 06:27:01 -04:00
jean-airoldie
7836ec752c Problem: Potentially unitialized variable in #3508
Solution: Initialized it
2019-05-15 05:35:58 -04:00
jean-airoldie
606a8f7967 Problem: Socket monitoring only allows ZMQ_PAIR
Solution: Allow ZMQ_PUB and ZMQ_PUSH sockets types for the monitoring.
This way someone could create a ZMQ_PULL socket connected to multiple
monitoring sockets at the same time.
2019-05-15 01:48:46 -04:00
Simon Giesecke
af4fa22fd8 Problem: default test setUp/tearDown functions duplicated in many test programs
Solution: define setUp/tearDown functions via SETUP_TEARDOWN_TESTCONTEXT macro where possible
2019-03-24 12:53:12 -04:00
Simon Giesecke
1450830611 Problem: unused include directives
Solution: remove and add where needed
2019-03-23 09:46:37 -04:00
Simon Giesecke
5d74eba64a Problem: remaining basic assertions
Solution: use unity assertions instead
2019-03-23 09:09:36 -04:00
Luca Boccassi
feadf6d40f Problem: cannot monitor state of queues at runtime
Solution: add API and ZMQ_EVENT_PIPES_STATS event which generates 2
values, one for the egress and one for the ingress pipes respectively.
Refactor the events code to be able to send multiple values.
2019-02-10 16:33:26 +00:00
Luca Boccassi
1e26a93ce2 Problem: test_monitor fails in valgrind
Solution: expect additional events
2019-02-07 20:42:47 +00:00
Luca Boccassi
edf79dfefc Problem: test_monitor check for DRAFT has to be kept up to date
Solution: check for the available version instead
2019-02-07 16:24:41 +00:00
Simon Giesecke
4273ffd266 Partially revert "Problem: monitor events are output as decimal in assertion messages"
This partially reverts commit 19c6aa5c92.
2019-02-07 10:42:32 -05:00
Simon Giesecke
19c6aa5c92 Problem: monitor events are output as decimal in assertion messages
Solution: output as hex instead
2019-02-06 07:11:10 -05:00
Simon Giesecke
a86592f78c Problem: test_monitor is not run for ipc and tipc
Solution: add test cases
2019-02-06 07:11:10 -05:00
Luca Boccassi
84847138a1 Problem: test_monitor fails with ipv6
Solution: correctly set the ipv6 flag in the connecting socket
2019-02-03 20:56:07 +01:00
Simon Giesecke
0e2e303b10 Problem: test_monitor is not run for ipv6
Solution: add test case using ipv6
2019-02-02 19:00:33 +01:00
Simon Giesecke
f3561f7759 Problem: no assertions for endpoint addresses on ZMQ_EVENT_MONITOR_STOPPED and ZMQ_EVENT_LISTENING events
Solution: added assertions
2019-02-02 18:29:33 +01:00
Simon Giesecke
5e2da02528 Problem: test case is leaking test socket
Solution: close test socket
2019-02-02 17:15:27 +01:00
Simon Giesecke
8f90f579f5 Problem: no assertions for local and remote addresses in monitor tests
Solution: added such assertions and extended test utilities
2019-02-02 16:34:19 +01:00
Simon Giesecke
b18d28eec1 Problem: no tests for v2 monitor events and test_socket_monitor_versioned
Solution: add first test case
2019-02-02 15:33:27 +01:00
Simon Giesecke
30e0cbbcdc Problem: test_monitor depends on testutil_security
Solution: move general monitoring test utilities to new testutil_monitoring
2019-02-02 15:33:27 +01:00
Simon Giesecke
367246bb23 Problem: test_monitor is not using a test framework
Solution: migrate to unity
2019-02-02 15:33:27 +01:00
Luca Boccassi
c347aef794 Problem: new DRAFT monitoring events are eligible for STABLE
Solution: do it
2018-11-18 13:23:38 +00:00
sigiesec
41f459e1dc Problem: formatting inconsistent
Solution: applied clang-format
2018-02-02 15:47:43 +01:00
Simon Giesecke
82227136ea Problem: test_monitor sometimes fails due to a wrong event received, but not known which
Solution: add diagnostic output
2017-08-21 12:20:36 +02:00
Simon Giesecke
5d4e30eb13 Replace console output by monitoring events for curve security issues (#2645)
* Fixing #2002 one way of doing it

 * Mechanisms can implement a new method `error_detail()`
 * This error detail have three values for the moment: no_detail
 (default), protocol, encryption.
    + generic enough to make sense for all mechanisms.
    - low granularity level on information.

* Fixing #2002: implementation of the error details

The ZMQ_EVENT_HANDSHAKE_FAILED event carries the error details
as value.

* Removed Microsoft extenstion for enum member access

This was leading to compilation error under linux.

* Adaptation of CURVE test cases

* Monitoring event: changed API for detailed events

Removed ZMQ_EVENT_HANDSHAKE_FAILED and replaced it by:
- ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL,
- ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL,
- ZMQ_EVENT_HANDSHAKE_FAILED_ENCRYPTION

Adaptation of text case `security_curve`

* Removed event value comparison

This was introduced for the previous API model adaptation

* Removed the prints in std output and added missing details

`current_error_detail` was not set in every protocol error cases

* Fixed initialization of current_error_detail

* Fixed error in greeting test case

The handshake failure due to mechanism mismatch in greeting is actually
a protocol error. The error handling method consider it like so and
send a protocol handshake failure monitoring event instead of no_detail.

Fixed the test_security_curve expectation as well.

* Upgraded tests of monitoring events

The tests check the number of monitoring events received

* Problem: does not build under Linux or without ZMQ_DRAFT_API

Solution:
- properly use ZMQ_DRAFT_API conditional compilation
- use receive timeouts instead of Sleep

* Problem: duplicate definition of variable 'timeout'

Solution: merged definitions

* Problem: inconsistent timing dependencies

Solution: reduce timing dependency by using timeouts at more places

* Problem: assertion failure under Linux due to unexpected monitor event

Solution: output event type to aid debugging

* Problem: erroneous assertion code

* Problem: assertion failure with a garbage server key due to an extra third event

Solution: changed assertion to expect three events (needs to be checked)

* Problem: extra include directive to non-existent file

Solution: removed include directive

* Problem: assertion failure on appveyor for unknown reason

Solution: improve debug output

* Problem: no build with libsodium and draft api

Solution: add build configurations with libsodium and draft api

* Problem: assertion failure on CI

Solution: change assertion to reflect actual behaviour on CI (at least temporarily)

* Problem: error in condition in assertion code

* Problem: assertion failure on CI

Solution: generalize assertion to match behavior on CI

* Problem: assertion failures on CI

Solution: removed inconsistent assertion on no monitor events before flushing
improved debuggability by converting function into macro

* Problem: diverging test code for three analogous test cases with garbage key

Solution: extract common code into function

* Problem: does not build without ZMQ_BUILD_DRAFT_API

Solution: introduce dummy variable

* Attempt to remove workaround regarding ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL again

* Problem: EAGAIN error after handshake complete if there is no more data in inbuffer

Solution: Skip tcp_read attempt in that case

* Problem: handshaking event emitted after handshaking failed

Solution: use stream_engine_t::handshaking instead of mechanism_t::status() to determine whether still handshaking

* Include error code in debug output

* Improve debugging output: output flushed events

* Split up ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL into ZMQ_EVENT_HANDSHAKE_FAILED_ZMTP and ZMQ_EVENT_HANDSHAKE_FAILED_ZAP

* Fixed compilation without ZMQ_BUILD_DRAFT_API

* Renamed ZMQ_EVENT_HANDSHAKE_SUCCEED to ZMQ_EVENT_HANDSHAKE_SUCCEEDED for language consistency

* Renamed ZMQ_EVENT_HANDSHAKE_SUCCEED to ZMQ_EVENT_HANDSHAKE_SUCCEEDED for language consistency

* Renamed ZMQ_EVENT_HANDSHAKE_SUCCEED to ZMQ_EVENT_HANDSHAKE_SUCCEEDED for language consistency

* Fixed assert_monitor_event (require event instead of allowing no event)
Reverted erroneous change to handshaking condition
Renamed test_wrong_key to test_garbage_key
Generalized assumption in test_garbage_key to allow for ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL with error == EPIPE

* Better isolate test cases from each other by providing a fresh context & server for each

* Added diagnostic output

* Changed assertion to reflect actual behavior on CI

* Fixed formatting, observe maximum line length

* Fixed formatting, observe maximum line length

* Increase timeout to check if this fixes valgrind run

* Close server with close_zero_linger

* Increase timeout to check if this fixes valgrind run

* Increase timeout to check if this fixes valgrind run

* Generalize assertion to also work with valgrind

* Fixed formatting

* Add more diagnostic output

* Generalize assertion to also work with valgrind
2017-08-03 14:15:56 +01:00
Luca Boccassi
5934919f3e Problem: tests bind to hardcoded TCP ports
Solution: use ZMQ_LAST_ENDPOINT in most places. This alllows running
tests in paralle, and on over-booked shared machines where many of
the ports would be already in use.
Keep 3 tests with an hardcoded port, as there are some code paths that
require it (eg: connect before bind), but list those ports in
tests/testutil.hpp as macros so that they do not overlap and still
allow parallel runs.

These changes were inspired by a patch uploaded to Ubuntu by the
package maintainer, Steve Langasek <steve.langasek@ubuntu.com>.
Thank you Steve!
2017-05-01 22:57:05 +01:00
Luca Boccassi
c0e2bc4ef9 Problem: new DRAFT monitor events returned even without --enable-draft
Solution: wrap the event triggering in the DRAFT ifdef as well as the
defines. This ensures that the event are returned only if the
library was built with DRAFTs enabled.

Also update the test case to expect the new events since it uses
the catch-all mask. Although the sequence of event is different and
this might be considered as an API breakage, using the catch-all
ZMQ_EVENT_ALL mask implies that, well, all events are monitored so
it's normal that new ones will be added.
Users that don't want this kind of behaviour to change can simply
monitor only the event that they care about.
2016-12-30 23:21:14 +01:00
hitstergtd
40dbbe342e Problem: bounce() arguments reversed
Solution:
Put them in the right order to quiet Coverity.

Found by:
Coverity Scan
2016-05-01 21:40:08 +01:00
Constantin Rack
a539b0c6e8 Problem: copyright year is still 2015
Solution: update to 2016
2016-01-28 15:07:31 +01:00
Brian Silverman
e449d7bfbd Fix test flakiness.
I'm pretty sure this is an issue with the test being too picky and not a
bug, but the behavior in this situation is not well documented.
2015-07-28 13:48:23 -07:00
Pieter Hintjens
8620c3e032 Problem: source file headers are somewhat confusing about LGPLv3
Of course people still "can" distributed the sources under the
LGPLv3. However we provide COPYING.LESSER with additional grants.

Solution: specify these grants in the header of each source file.
2015-06-02 22:33:55 +02:00
Pieter Hintjens
94d9a4ffdf Problem: copyright statements are out of date
Solution: update for 2015

Fixes #1320
2015-01-22 10:32:37 +01:00
Pieter Hintjens
9753de8566 Problem: zmq_socket_monitor code is dirty
Specifically:

* zmq_event_t should not be used internally in libzmq, it was
  meant to be an outward facing structure.

* In 4.x, zmq_event_t does not correspond to monitor events, so
  I removed the structure entirely.

* man page for zmq_socket_monitor is incomplete and the example
  code was particularly nasty.

* test_monitor.cpp needed rewriting, it was not clean.
2014-04-28 11:30:49 +02:00
Pieter Hintjens
b3b9e046ee Updated copyright statements for 2014 2014-01-02 12:00:57 +01:00
Pieter Hintjens
5b60540ed0 Removed over-long pauses in tests
- used msleep (10) in most places instead of zmq_sleep (1)
- may cause failures on slower machines
- to change, modify SETTLE_TIME in testutil.h
- tested down to 1 msec on fast boxes
2013-11-06 13:42:57 +01:00
Pieter Hintjens
576e3ca5e0 Added z85 codec to ZMQ API
* Removed redundant Z85 code and include files from project
* Simplified use of headers in test cases (now they all just use testutil.hpp)
* Export zmq_z85_encode() and zmq_z85_decode() in API
* Added man pages for these two functions
2013-09-15 20:13:44 +02:00
Richard Newton
a83baa9b0b Fix up threading code from port tests to windows. 2013-08-17 14:23:22 +01:00
Richard Newton
7f74fc7c99 Port tests to windows and add to cmake build. 2013-08-17 13:43:45 +01:00
Richard Newton
998610602e Fix tab/space formatting issue 2013-07-01 12:10:57 +01:00
Richard Newton
f6e972d546 Fix montior tests to handle the monitor stopped event correctly 2013-07-01 10:31:57 +00:00
Pieter Hintjens
fadfcac1de Fixed compile error, needed unistd.h 2013-06-22 13:50:22 +02:00
Ian Barber
f4c51db842 Fix small streamengine issue w/ term and handshake
Also tidy up monitor test a little.
2013-06-22 10:58:16 +01:00
Pieter Hintjens
f1738b9b92 More copyright cleanups 2013-03-12 17:04:51 +01:00
Guido Goldstein
b0b8ab27c5 Changed message structure for event notifications. 2013-03-08 13:48:18 +01:00
Guido Goldstein
21eeb03b6c Simplified the zmq_event_t structure for easier access and better usability towards language bindings. 2013-03-08 10:34:25 +01:00
Pieter Hintjens
963c6a8e2f Lots of cleanups to self-tests
* Removed or truncated sleeps so the tests run faster
* Removed dependencies on zmq_utils
* Rewrote a few tests that were confusing
* Minor code cleanups
2013-01-31 19:46:22 +01:00