Commit Graph

832 Commits

Author SHA1 Message Date
sigiesec
a71f7b0405 Problem: zmq_poller_* uses ETIMEDOUT (instead of the usual EAGAIN) to indicate timeouts
Solution: replace ETIMEDOUT within socket_poller_t and all client code by EAGAIN

Fixes #2713
2017-08-22 20:00:29 +02:00
sigiesec
6a3c053a3e Problem: EFAULT is returned for bad file descriptors passed to zmq_poller_*_fd
Solution: Return EBADF instead
2017-08-22 19:43:56 +02:00
sigiesec
74303b08e6 Problem: calling zmq_poller_wait* with NULL events causes an assertion, as opposed to other NULL arguments, which return an error
Solution: return EFAULT when such an operation is attempted
2017-08-22 19:43:56 +02:00
sigiesec
c1a4cfdd9f Problem: waiting on an empty poller with infinite timeout waits forever
Solution: return EFAULT when such an operation is attempted
2017-08-22 19:43:56 +02:00
sigiesec
0c9b16d62a Problem: missing test cases for zmq_poller_* functions called with invalid arguments and corner cases for zmq_poller_wait_*
Solution: added test cases
2017-08-22 19:43:42 +02:00
sigiesec
2e4fc4faf0 Problem: zmq_poller_*_fd functions do not check for invalid fd
Solution: add checks, added test cases
2017-08-22 19:28:07 +02:00
sigiesec
f9af5503b4 Problem: missing test cases for zmq_poller_* functions called with invalid arguments
Solution: added test cases
2017-08-22 19:28:07 +02:00
sigiesec
9a336622fb Problem: no tests for socket-related functions passing NULL as socket
Soluton: added tests
2017-08-22 16:22:38 +02:00
Simon Giesecke
0aef54421d Problem: test_monitor is disabled on Windows
Solution: enable test
2017-08-21 12:20:37 +02: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
74203729bd Problem: test_zap_unsuccessful_status_500 and test_curve_security_with_bogus_client_credentials sometimes fail, particulary on slow/valgrind runs
Solutio: relax test assertion
2017-08-20 22:47:15 +02:00
sigiesec
bd0675b93f Problem: no tests for client-side events for successful handshake and authentication failure in handshake
Solution: added tests for CURVE, add emitting of client-side event in curve_client_t; add ZAP code 300/500 tests for all mechanisms; suppress sending an error message for ZAP code 300
2017-08-20 22:45:14 +02:00
Luca Boccassi
b239d99a2c Problem: test_security_gssapi does not close messages
Solution: do it to avoid leaks. Even though they are below 33 bytes so
it's all allocated on the stack, the small message size might change in
the future.
2017-08-20 11:54:49 +01:00
Luca Boccassi
cd09065c8a Problem: test_security_gssapi expects wrong event
Solution: fix it
2017-08-20 11:54:13 +01:00
Simon Giesecke
00c6962516 Problem: test failing due to too few messages sent relative to SNDHWM
Solution: relaxed assertion to accept 10% of the SNDHWM, and updated documentation accordingly
2017-08-20 11:51:09 +02:00
sigiesec
4c2acdacca Problem: wrong assumption on behavior of ZMQ_SNDHWM in test_sockopt_hwm.cpp
Solution: align assertions with specification of ZMQ_SNDHWM (actual number of enqueueable messages may be lower)
2017-08-20 11:43:13 +02:00
Luca Boccassi
90b6c102bb Problem: various unused variables warnings
Solution: use LIBZMQ_UNUSED where necessary
2017-08-19 12:18:51 +01:00
Luca Boccassi
5b1c0cd0ac Problem: test_security_gssapi fails to build
Solution: monitor new events only if DRAFT APIs are enabled, and
convert to new event types. Same for DRAFT socket options.
2017-08-18 16:56:36 +01:00
Luca Boccassi
330856daec Problem: double definition in test_security_gssapi
Solution: remove the second one to fix build failure
2017-08-18 16:28:03 +01:00
sigiesec
301f3c70c2 Problem: code duplication between curve_client_t and curve_server_t decode and encode
Solution: extracted common base class curve_mechanism_base_t
2017-08-18 11:34:22 +02:00
sigiesec
e2d3ba9c62 Problem: classification ZMQ_HANDSHAKE_FAILED_* events is coarse-grained and partially misleading
Solution: redesign ZMQ_HANDSHAKE_FAILED_* events, introduce new class of ZMQ_HANDSHAKE_FAILED_AUTH events
2017-08-18 09:17:59 +02:00
sigiesec
863a02b4a1 Problem: no ZAP tests for PLAIN mechanism
Solution: added ZAP tests for PLAIN
2017-08-17 12:22:26 +02:00
sigiesec
00816875b8 Problem: no ZAP tests for NULL mechanism
Solution: added ZAP tests for NULL
2017-08-17 12:11:14 +02:00
sigiesec
406af1ef67 Problem: ZAP tests are now generic but placed in test_security_curve.cpp
Solution: Move ZAP tests to own file test_security_zap.cpp, move common code to testutil_security.hpp
2017-08-17 11:45:18 +02:00
sigiesec
59d8060165 Problem: ZAP tests are only run with CURVE security
Solution: as a first step, parametrize mechanism configuration in CURVE tests
2017-08-17 11:10:11 +02:00
Simon Giesecke
4a18f6204c Problem: Possible buffer overruns related to metadata in various mechanisms (#2683)
* Problem: no test case with CURVE encryption and large identity

Solution: added test case (currently crashing)

* Problem: possible buffer overflow in mechanism_t::add_property

Solution: add target buffer length parameter and check the buffer is sufficiently large

* Problem: test cases accidentally excluded from build

Solution: remove #if/#endif

* Problem: possible buffer overruns related to metadata at various locations

Solution: allocate buffer large enough for actual metadata, reduce code duplication

* Problem: syntax error related to pointer type conversion

Solution: change argument type of make_command_with_basic_properties to const char *

* Problem: large metadata may cause an assertion in produce_initiate

Solution: Allow metadata of arbitrary size in produce_initiate
2017-08-15 18:42:31 +01:00
Simon Giesecke
d5e4319edc [WIP, do not merge] Problem: insufficient tests for ZMTP-CURVE protocol errors (#2680)
* Extracted connect_vanilla_socket function

* Problem: no tests for ZMTP-CURVE protocol errors

Solution: added two test cases with erroneous HELLO commands

* Problem: insufficient tests for ZMTP-CURVE protocol errors

Solution: added two test cases with erroneous HELLO command version

* Problem: test HELLO message is invalid apart from deliberate errors

Solution: create cryptographically correct HELLO message
add tweetnacl.c to test_security_curve

* Problem: nonce is incorrect, build fails with GCC

Solution: use correct non prefix

* Problem: make builds are failing

Solution: transfer CMake changes to (auto)make files

* Problem: nonce is incorrect, build fails with GCC

Solution: use correct non prefix

* Problem: make builds are failing

Solution: transfer CMake changes to (auto)make files

* Problem: no test with INITIATE command with invalid length

Solution: added test case

* Problem: code duplication between test_security_curve.cpp and curve_client.cpp

Solution: extracted parts of zmq::curve_client_t::produce_hello into reusable function

* Problem: code duplication between test_security_curve.cpp and curve_client.cpp

Solution: extracted further parts of zmq::curve_client_t into reusable functions
added missing file

* Problem: mechanism_t::add_property can be declared static

Solution: declare mechanism_t::add_property static

* Problem: intermediate crypto data needs to be passed between static function calls to curve_client_tools_t

Solution: add non-static member functions

* Problem: msg_t instance may be closed twice

Solution: remove offending close

* Problem: prepare_hello uses static curve_client_tools_t::produce_hello

Solution: Use non-static curve_client_tools_t::produce_hello

* Problem: no test with invalid command name where INITIATE command is expected

Solution: added test case

* Problem: make builds are failing due to curve_client_tools.hpp not being found

Solution: add curve_client_tools.hpp to list of source files

* Problem: wrong initializer order in zmq::curve_client_t

Solution: reorder

* Problem: under non-Windows systems, test fails because random_open was not called

Solution: call random_open/random_close within test

* Problem: conflict between custom function htonll and macro definition on Darwin

Solution: define htonll function only if not defined as a macro

* Problem: nullptr not defined on all platforms

Solution: replace nullptr by NULL

* Problem: libsodium builds not working

Solution: adapt compile and link file sets for libsodium builds

* Problem: Makefile.am broken

Solution: Fix syntax

* Problem: no tests for garbage encrypted cookie or content in INITIATE

Solution: added test cases

* Problem: test cases accidentally excluded from build

Solution: remove #if/#endif

* Solution: some error cases are unreachable

Problem: for the time being, added some comments without changing the code

* Added comments on hard-to-test cases
2017-08-15 15:28:24 +01:00
Simon Giesecke
a6cef4ef86 Problem: ZAP status codes != 200 do not result in an appropriate monitor event (#2665)
* Problem: missing test for status code 300, inadequate assertion for status code 500

Solution: add test, change assertion (currently test fails)

* Problem: gcc compiler error deprecated conversion from string constant

Solution: declare variable as const

* Problem: in case of ZAP handler returning a status code other than 200, no appropriate event is emitted

Solution: immediately emit event after receiving reply from ZAP handler

* Problem: endpoint address is not included in zap-reply monitor event

Solution: added functions to retrieve endpoint address in zmq::i_engine and zmq::session_base_t
removed unused code block in zmq::stream_engine_t::next_handshake_command

* Problem: wrong formatting

Solution: fix formatting

* Problem: test fails because of EPIPE

Solution: add EPIPE/ECONNRESET/ECONNAGAIN handling for more test cases
2017-08-08 13:10:20 +01:00
Simon Giesecke
834b9e4cd7 Problem: some test cases may still fail because of EPIPE/ECONNABORT/ECONNRESET (#2664)
* Problem: CI failure on Appveyor with err==ECONNRESET

Solution: ignore ECONNRESET analogous to EPIPE

* Problem: blocking test execution

Solution: added more debug output, do not wait for monitor infinitely without output
2017-08-07 17:07:37 +01:00
Jim Klimov
612d81a831 Merge pull request #2659 from bluca/fix_getrandom
Problems: test_security_curve occasionally hangs or fails due to ECONNABORTED
2017-08-07 12:36:59 +02:00
Luca Boccassi
20bbd016c1 Merge pull request #2663 from sigiesec/fix-zap-assertion
Problem: failing assertion on ZAP protocol error
2017-08-07 11:15:54 +01:00
Simon Giesecke
de82cbe4ba Problem: failing assertion on ZAP protocol error
Solution: do not assert on ZAP protocol error when connection was closed by client
2017-08-07 10:59:36 +02:00
Simon Giesecke
8842e0f0a9 Problem: occasional test failures due to messages not (yet) received in test assertion
Solution: add sleep
2017-08-07 10:35:25 +02:00
Luca Boccassi
5f6ff69f62 Problem: test_security_curve fails due to ECONNABORTED
Solution: expect that error, which can happen on very slow machines
due to a client timimng out or RST before the connection is accepted
by the server
2017-08-07 09:26:38 +01:00
Luca Boccassi
1c1f10a25a Problem: test_security_curve occasionally hangs
Solution: refactor the ZAP thread to avoid creating the socket in the
main thread and using it in the ZAP thread, and also to eliminate
races at shutdown use another inproc control socket to signal
termination to the thread
2017-08-07 09:18:37 +01:00
Luca Boccassi
14df80ae3a Problem: test_security_curve does not account for ECONNRESET
Solution: ignore ECONNRESET as with EPIPE - it can happen on very
slow machines when the engine sends data to the peer and then tries
to read from the TCP socket before the peer has read
2017-08-05 18:08:21 +01:00
Luca Boccassi
9c085381ee Problem: test_security_curve timeouts on CMake
Solution: bump timeout from 20 to 60 seconds
2017-08-04 16:25:59 +01:00
Simon Giesecke
7ba70e95e5 Problem: test failure on CI due to ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL/EPIPE problem
Solution: add workaround at another place, unify two code fragments to remove duplication
2017-08-04 16:05:20 +02:00
Simon Giesecke
aacb219acd Problem: open TODOs in test code
Solution: removed code duplication
improved global variable naming
added assertions on number of ZAP requests handled
added assertion on monitor event to test_curve_security_with_plain_client_credentials
2017-08-04 15:11:14 +02:00
Jim Klimov
e84804d4cc Merge pull request #2647 from bluca/travis_test
Problems: too many OSX travis builds, curve test uses hard-coded TCP port
2017-08-04 13:21:02 +02:00
Luca Boccassi
32085870df Merge pull request #2650 from sigiesec/connection-close-event-workaround
Problem: sporadic failure in test_curve_security_with_null_client_credentials
2017-08-04 11:48:27 +01:00
Simon Giesecke
4b847f3ff9 Problem: no tests for ZAP handler that has an invalid protocol (#2648)
* Problem: no tests for ZAP protocol errors

Solution: added first test for a bogus version number in ZAP reply

* Problem: no tests for ZAP protocol errors

Solution: added more test cases

* Problem: cannot compile without ZMQ_BUILD_DRAFT_API

Solution: conditionally compile parts that depend on draft API

* Problem: test_security_curve times out in CI

Solution: Increase timeout for this test to 20 seconds
2017-08-04 11:07:41 +01:00
Simon Giesecke
4fec4c99be Problem: sporadic failure in test_curve_security_with_null_client_credentials
Solution: add workaround for EPIPE error
2017-08-04 11:35:00 +02:00
Luca Boccassi
ccb1250fcc Problem: a curve test uses hard-coded TCP port
Solution: use the wildcard endpoint instead
2017-08-03 14:41:36 +01: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
415bdbc1b9 Problem: ZMQ_BINDTODEVICE is DRAFT but not DRAFT
Solution: move definition in the DRAFT section of the header
2017-07-31 16:31:31 +01:00
Brian Russell
b963542e8f Add socket option BINDTODEVICE
Linux now supports Virtual Routing and Forwarding (VRF) as per:

https://www.kernel.org/doc/Documentation/networking/vrf.txt

In order for an application to bind or connect to a socket with an
address in a VRF, they need to first bind the socket to the VRF device:

    setsockopt(sd, SOL_SOCKET, SO_BINDTODEVICE, dev, strlen(dev)+1);

Note "dev" is the VRF device, eg. VRF "blue", rather than an interface
enslaved to the VRF.

Add a new socket option, ZMQ_BINDTODEVICE, to bind a socket to a device.
In general, if a socket is bound to a device, eg. an interface, only
packets received from that particular device are processed by the socket.

If device is a VRF device, then subsequent binds/connects to that socket
use addresses in the VRF routing table.
2017-07-31 15:31:47 +01:00
Luca Boccassi
3536c4b9c4 Problem: XPUB_MANUAL subscriptions not removed on peer term
Solution: remove the pipe from the real trie when a peer disconnects.
Also add a unit test that exercises the behaviour by reconnecting
a different socket and sending a message that matches.
Fixes #2601 and introduced by #2042
2017-06-22 01:02:08 +01:00
Luca Boccassi
8e2027983a Problem: XPUB_MANUAL takes effect for the next bind
Solution: fix unit test to bind after setting the option.
2017-06-22 00:58:44 +01:00
Joe Eli McIlvain
2d83acceff Merge pull request #2596 from bluca/zap_curve
Problems: ZAP can be set up incorrectly, CURVE and GSSAPI can be used only with ZAP
2017-06-15 11:51:43 -07:00
Iban Cereijo
2c4e5364aa Problem: missing Ws2_32.lib when cross compiling
Solution: use lower case ws2_32.lib to enable cross compilation
from platforms with case-sensitive filesystems.

When cross compiling the tests with Mingw-w64, CMake cannot
locate Ws2_32.lib
2017-06-14 15:54:03 +02:00
Luca Boccassi
0ce18eac25 Problem: CURVE can no longer be used without ZAP
Solution: revert change that made ZAP mandatory.
The "Stonehouse" pattern, where CURVE is used only for encryption and
without authentication, is a valid use case so we should still
support it.
Also restore CURVE testing in the test_heartbeat.

Fixes #2594
2017-06-13 22:56:32 +01:00
Luca Boccassi
17637536b8 Problem: use-after-free in test_poller
Solution: remove server socket from poller before closing it
Fixes #2581
2017-05-18 13:10:19 +01:00
Luca Boccassi
bdc676f687 Problem: REP leaves label msgs for dead REQ in pipe
Solution: roll back the pipe if writing messages other than the
first fails in router::xsend. Roll it back also when the pipe is
terminating.
Also add test case that reproduces the memory leak when ran with
valgrind.
Fixes #2567
2017-05-17 09:18:15 +01:00
BJovke
1489fc1ac5 Revert "Problem: REP leaves label msgs for dead REQ in pipe" 2017-05-16 11:20:03 +02:00
Luca Boccassi
0999fdd885 Problem: REP leaves label msgs for dead REQ in pipe
Solution: roll back the pipe if writing messages other than the
first fails in router::xsend.
Also add test case that reproduces the memory leak when ran with
valgrind.
Fixes #2567
2017-05-10 23:44:03 +01:00
Luca Boccassi
b29d46b6a5 Problem: tests use same IPC endpoint
Solution: use either a wildcard IPC, or where the codepath needs to
be tested a file named after the test, so that it is unique and there
is no clash on the filesystem, allowing parallel test runs.
2017-05-01 22:57:05 +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
Jim Garlick
edd6b0ad01 gssapi: add a basic test for GSSAPI security
Problem: there is no test coverage for GSSAPI.

Solution: add a test structured like the CURVE test.

The test is not built if libzmq is not configured with
--with-libgssapi_krb5. It will report SKIPPED status
if the required environment is missing (see below).

Environment:  KRB5_KTNAME and KRB5_CLIENT_KTNAME
environment variables must point to a keytab file
containing creds for a host-based test principal
(see comment at top of source for details).
Kerberos must be configured and a KDC containing the
test principal must be running, otherwise the test
will fail/hang.

N.B. For now, the test must use the same principal for
both client and server roles because it seems impossible
to set them to different principals when they are
threads in the same process.  Once one principal is
cached in credential cache, attempts to acquire creds
for a different "desired name" seem to be ignored and
the cached principal is used instead.
2017-04-26 09:31:21 -07:00
Yann Diorcet
17460b3b2b Targets broken by some parts of f7d1c159d4 2017-04-24 15:57:14 +02:00
Yann Diorcet
f7d1c159d4 Fix windows compilation 2017-04-12 10:59:04 +02:00
Stefan Herbrechtsmeier
2f367bddf7 cmake: Remove build/msvc include path to remove file name clash
Remove the `build/msvc` include path from the test project to fix a
problem with the order of the include paths. Additionally remove the
unnecessary `include_directories` from the master project.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
2017-04-05 10:03:07 +02:00
evoskuil
7952c584b6 Problem: xpub test has broken style (missing whitespace). 2017-03-30 14:45:48 -07:00
evoskuil
0bfd747af8 Problem: heartbeats test has invalid curve design; xplat and style probs. 2017-03-29 17:43:25 -07:00
Goswin von Brederlow
1dd5fef20c zmq_curve_keypair(): return result from crypto_box_keypair() to make testcase meaningfull 2017-03-16 14:01:08 +00:00
Luca Boccassi
0f473d14cb Problem: unnecessary change to router_mandatory_hwm test
Solution:

Revert "Problem with ZMQ_ROUTER_MANDATORY option when peer lost"

This partially reverts commit 06740b5d8c.

The change in the mentioned commit was fixed to be backward
compatible so test changes are no longer necessary.
Partially revert the commit, leaving only the bug fix and taking out
the test change and the superfluous change in socket_base.
2017-02-24 17:57:14 +00:00
Reza Ebrahimi
06740b5d8c Problem with ZMQ_ROUTER_MANDATORY option when peer lost
indention

Revert "indention"

This reverts commit a6e7e192ac2d089ac9f7dc0d31d4b1fd10de982e.

indention

indention

Fix Failure in tests

Check both pipe full and pipe close
2017-02-24 20:49:26 +03:30
sigiesec
c6c21cf197 Problem: zmq_z85_decode does not validate its input (#2322)
* Problem: zmq_z85_decode does not validate its input
Solution: added checks for invalid characters and overflows

* Added tests, added further check for range overflow, removed (multiple) calls to strlen

* Problem: gcc fails to build
Solution: added missing include directive

* Added VS2015 test_utils_z85 project

* Fixed indentation and copyright notice

* Resolved garbage from merge

* Revert "Added VS2015 test_utils_z85 project"

This reverts commit c58b3c664c.

* Problem: test calls zmq_z85_decode with a NULL dest
Solution: call zmq_z85_decode with a properly sized buffer

* Problem: tests for zmq_z85_* scattered over two files
Solution: merged files

* Removed reference to removed test file from CMakeLists.txt

* Problem: Missing include directive to stdint.h
Solution: Added include directive

* Define __STDC_LIMIT_MACROS before including stdint.h

* Problem: Wrong variable is checked for invalid character marker
Solution: Use correct variable
2017-01-25 14:28:03 +00:00
Asmod4n
b7cd6e8a85
add test and documentation for "draft" capability 2017-01-19 20:50:18 +01:00
Luca Boccassi
7e186432cb Problem:capitalized include filenames trip mingw
Solution: use lowercase
2017-01-03 14:59:57 +01:00
Vincent Tellier
ea7e03a7ff Fixed issue #2286 by documentation
tests/README.md explicitly indicates to check the libzmq.lib path in
CMakeLists.txt.
2017-01-01 19:08:28 +01:00
Luca Boccassi
3f3601e855 Problem: handshake events not tested with curve
Solution: check that the expected handshake success or failure events
are triggered in the curve security unit test
2016-12-31 01:31:37 +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
Luca Boccassi
113feb60a2 Problem: ZMQ_MSG_T_SIZE draft but not in DRAFT section
Solution: move it there, add it to src/zmq_draft.h and clarify in the
documentation and in the NEWS file that this option is not yet stable
2016-12-29 21:07:39 +01:00
Luca Boccassi
06055a7b74 Problem: cmake does not run test_zmq_poll_fd
Solution: add it to the list
2016-12-26 19:20:09 +01:00
Luca Boccassi
272d340c1f Problem: no mixed FD and zmq socket zmq_poll test
Solution: add one
2016-12-15 12:03:48 +00:00
Luca Boccassi
dcec022358 Problem: test_stream_exceeds_buffer does not build on AIX
Solution: add missing includes
2016-12-06 20:34:10 +00:00
Luca Boccassi
8325355d73 Problem: test_stream_exceeds_buffer has redundant includes
Solution: remove them as they are already in testutil.hpp
2016-12-06 20:33:46 +00:00
Luca Boccassi
670bec56d8 Problem: size of zmq_msg_t is not known to FFI wrappers
Solution: add a ZMQ_MSG_T_SIZE context read-only option so that
wrappers can call zmq_ctx_get (ctx, ZMQ_MSG_T_SIZE) to get the
size at runtime.
2016-11-20 12:24:03 +00:00
Harald
6f597d0bd3 Problem: CMake build rejects to build with openpgm enabled
Solution: add optional lookup for openpgm via pkg-config
2016-11-01 12:31:40 +01:00
Luca Boccassi
25bf30bebe Problem: 2 connects with same sourceip:port to different destip:port fail
Solution: during a connect with a TCP endpoint if a source address is
passed set the SO_REUSEADDR flag on the socket before the bind system
call.
Add unit test to cover this case for both IPv4 and IPv6.
2016-10-23 22:31:45 +01:00
Nick Guiffrida
ffdb44ad2c Fix zmq_poll return code assert in tests/test_radio_dish.cpp 2016-09-30 21:50:31 -07:00
Min RK
bdcaa935b9 zmq_poll calls zmq_poller if available
enables zmq_poll on threadsafe sockets only supported in zmq_poller (radio, dish, etc.)
2016-09-28 13:53:57 +02:00
Luca Boccassi
fab846a5e5 Problem: zmq_ctx_term asserts with connect-before-bind and sockets with identity over inproc transport
Solution: check if the connecting inproc socket has been closed
before trying to send the identity.
Otherwise the pipe will be in waiting_for_delimiter state causing
writes to fail and the connect to assert when the context is being
torn down and the pending inproc connects are resolved.
Add test case that covers this behaviour.
2016-09-24 18:59:29 +01:00
Luca Boccassi
25402335fd Problem: no bind-after-connect TCP test
Solution: add one to increase coverage
2016-09-24 18:27:19 +01:00
Luca Boccassi
53e5a9a6f9 Problem: zmq_connect with IPv6 "source:port;dest:port" format is broken
Solution: allow for '[' character when doing the basic sanity check
on the TCP endpoint.
Also add unit tests for both IPv4 and IPv6 source;dest format.
2016-09-17 20:04:40 +01:00
Luca Boccassi
c1d07c6cd6 Problem: test_reqrep_tcp does not have IPv6 tests
Solution: add them
2016-09-17 20:04:40 +01:00
Luca Boccassi
896192ff42 Problem: test_reqrep_tcp does not test multiple endpoints
Solution: add a test for this use case
2016-09-17 19:30:59 +01:00
Luca Boccassi
75219e33a7 Problem: test_reqrep_tcp does not test disconnect/unbind
Solution: add disconnect and unbind calls to the test
2016-09-17 19:30:35 +01:00
Luca Boccassi
8d723fee3d Problem: test_reqrep_tcp is too limited
Solution: refactor it to allow for multiple functionalities to be
tested
2016-09-17 19:30:22 +01:00
Thomas Braun
c9c49f3e9f Problem: Missing newline in printf statement
Solution: Add "\n" at end of format string.
2016-09-12 19:45:31 +02:00
Luca Boccassi
a9343dbbc3 Problem: testutil.hpp fails to build on Windows XP
Solution: ifdef is_ipv6_available to always return false if building
on Windows XP, as it doesn't support the needed standard libc
functions
2016-08-27 16:48:38 +01:00
Luca Boccassi
0002824fc0 Problem: is_ipv6_available needs context to work on Windows
Solution: call the function after the zmq_ctx has been created, not
before, so that the relevant Windows system calls have been setup.
2016-08-23 21:48:57 +01:00
Luca Boccassi
f486176741 Revert "is_ipv6_available: Create a fake zmq context on windows"
This reverts commit 9adf20aaeb.
2016-08-23 21:46:43 +01:00
Thomas Braun
9adf20aaeb is_ipv6_available: Create a fake zmq context on windows
This is required as zmq_ctx_new calls WSAStartup. Without that the IPV6
socket creation always fails.
2016-08-23 21:52:16 +02:00
Giuseppe Corbelli
7fdb167732 [tests/testutil.hpp] Problem: wrong windows.hpp path
Solution: correct path is ../src/windows.hpp. Also added automatic linking
of iphlpapi library if required and using MSVC
2016-07-12 15:58:17 +02:00
Giuseppe Corbelli
0b01cc1ebc [tests/CMakeLists.txt] Problem: The libzmq.lib search path should be set
only if the library is found at a specific path

Solution: Search for libzmq.lib in ../bin/Win32/Debug/v120/dynamic, don't
know how to automatically search in correct path based on current build
configuration
2016-07-12 15:54:55 +02:00
Fedor Sheremetyev
813c738137 Add test for consistent unsubscription in XPUB manual mode.
Expect custom messages on both explicit unsubscription and pipe termination.
2016-06-17 11:36:13 +01:00
evoskuil
c050d95fcd Problem: no unit tests for base85 or public curve functions. 2016-05-19 03:46:15 -07:00
hitstergtd
fed17746c6 Problem: Wrapping issue in test for SRCFD [style]
Solution:
Wrap it.
2016-05-16 20:47:47 +01:00
somdoron
c4d0146f2c problem: udp doesn't enforce correct usage of bind/connect
solution: enforce that dish and gram can only bind and radio can only
connect
2016-05-16 13:34:38 +03:00
somdoron
6db8f1e74b problem: test is using connect with dgram, dgram only support bind 2016-05-16 12:18:30 +03:00
Bitiquinho
23b3403fa5 Remove printf and add asserts on test 2016-05-15 15:37:33 -03:00
Bitiquinho
977e700893 Fix Copyright range 2016-05-15 15:37:33 -03:00
Bitiquinho
da14bb4bc2 Added ZMQ_DGRAM tests to build (Makefile.am and CMakeLists.txt) 2016-05-15 15:37:33 -03:00
Bitiquinho
94c53e541d Added test for ZMQ_DGRAM socket type (unicast and multicast) 2016-05-15 15:37:33 -03:00
Constantin Rack
bd66cfe6f8 Merge pull request #1991 from hitstergtd/x-testcov-zmq-2
Problem: zmq_poller_destroy can segfault
2016-05-14 08:17:41 +02:00
Joe Eli McIlvain
71ba7df781 Merge pull request #1987 from hitstergtd/x-reduce-cliserv-sends
Problem: test send count too high for AppVeyor CI environment
2016-05-12 20:15:08 -07:00
hitstergtd
e82e4ea13e Problem: test send count too high for AppVeyor
Solution:
Reduce send count so that the test does not timeout on AppVeyor CI
environment and older Windows boxes.
2016-05-13 04:04:08 +01:00
hitstergtd
477cc1cb12 Problem: zmq_poller_destroy parameter checking
Solution:
- Add checks for **poller_p_ to ensure that we do not segfault when either it
  or the value within it are NULL
- Add tests for the above and increase error state coverage
2016-05-12 18:09:59 +01:00
hitstergtd
4842b6bd81 Problem: No coverage for ctx termination errors
Solution:
- Add error state coverage for zmq_ctx_term(), zmq_term() and
  zmq_ctx_shutdown(); zmq_ctx_destroy() is already covered since it only
  calls zmq_ctx_term()
- Add coverage for zmq_term()
2016-05-12 17:47:08 +01:00
Erik Hugne
f81ef1bc72 tipc: add support for address domain suffix
The TIPC protocol bindings in ZeroMQ defaults to a lookup domain
of 1.0.0 to prevent 'closest first' search, and instead always
do round robin if several sockets in the network or node have
the same name published. In retrospect, this might have been a
bad idea because it won't work on standalone configurations.
We solve this by allowing an optional domain suffix to be provided
in the address, and 0.0.0 should be used in that case, or if the
TIPC address range in the cluster configuration is defined to some
other value. Domain suffixes are only relevant for connecting
addresses.

Signed-off-by: Erik Hugne <erik.hugne@gmail.com>
2016-05-11 21:54:25 +02:00
hitstergtd
206771afd2 Problem: Not all ancillary API methods tested
Solution:
- Add file for testing ancillary API methods and any misc internal machinery
- Add tests for zmq_version(3) and zmq_strerror(3)
- Add test file into gitignore, Autotools and CMake build files
- Increase test coverage

Note:
MSVC solution files have not been updated.
2016-05-08 18:25:03 +01:00
Doron Somech
be741f604a problem: timers test is flapping on windows 2016-05-05 14:24:47 +03:00
Doron Somech
a747f72450 problem:closed poller still associated with socket 2016-05-05 13:50:33 +03:00
somdoron
50c2f7af8f fix sndbuf/rcvbuf tests 2016-05-03 19:46:34 +03:00
Luca Boccassi
6de24c190a Problem: scatter/gather are not yet stable APIs
Solution: mark them as DRAFT APIs
2016-05-02 21:47:05 +01:00
Luca Boccassi
caaf66c32c Problem: radio/dish are not yet stable APIs
Solution: mark them as DRAFT APIs
2016-05-02 21:47:05 +01:00
Luca Boccassi
32a1ef85a8 Problem: zmq_timers* are not yet stable APIs
Solution: mark them as DRAFT APIs
2016-05-02 21:47:05 +01:00
Luca Boccassi
738968082b Problem: zmq_poller* are not yet stable APIs
Solution: mark them as DRAFT APIs
2016-05-02 21:47:05 +01:00
Luca Boccassi
7e700f1e73 Problem: client/server are not yet stable APIs
Solution: mark them as DRAFT APIs
2016-05-02 21:47:05 +01:00
Luca Boccassi
064cd1fbfb Problem: no support for DRAFT API in build systems
Solution: add support for --enable-drafts/ENABLE_DRAFTS=ON in
Autools and CMake.
2016-05-02 21:47:05 +01:00
Luca Boccassi
f0a34e0ff5 Problem: test_poller/use_fd_ipc/tcp use draft API
Solution: only use ZMQ_SERVER/CLIENT if the defines are available.
2016-05-02 21:46:47 +01:00
Luca Boccassi
c293618ae8 Problem: testutil.hpp includes platform.hpp last
Solution: before including internal headers, include platform.hpp
so that the build time options are correctly applied to the included
headers.
2016-05-02 20:00:53 +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
hitstergtd
e4539778a4 Problem: multiple issues with sendiov/recviov
Solution:
- Add check for the [count] parameter in zmq_sendiov() and zmq_recviov()
- Use and add test for zmq_sendiov() in tests/test_iov.cpp
- Add error state tests for zmq_sendiov() in tests/test_iov.cpp
- Add error state tests for zmq_recviov() in tests/test_iov.cpp
- Cleanup tests/test_iov.cpp for style, consistency and clarity
- Generally improve test coverage for both API methods

Hat-tip:
@somdoron, @bluca
2016-05-01 19:41:50 +01:00
Luca Boccassi
95acb29bfb Merge pull request #1934 from somdoron/master
problem: no documentation for Radio-dish and UDP
2016-04-29 10:40:56 +01:00
somdoron
34d5028ea8 allow specify binding address on radio with udp 2016-04-29 12:17:17 +03:00
hitstergtd
8872809337 Problem: XPUB test broken since #1566 on Windows
Solution:
- Adjust test_xpub_proxy_unsubscribe_disconnect() to support different
  protocol types
- Exclude the IPC tests on Windows and OpenVMS

H/T: @somdoron
2016-04-24 16:56:06 +01:00
Doron Somech
0655ed2e0e fix test unbind wildcard 2016-04-23 22:30:10 +03:00
Doron Somech
0934bc784d fix test term endpoint 2016-04-23 22:30:09 +03:00
Luca Boccassi
a93600309f Problem: assertion in test_xpub_manual is swapped
Solution: check that both pointers passed as arguments to
test_missing_subscription are non-NULL, instead of the opposite.
2016-04-23 18:16:49 +01:00
hitstergtd
ff02862171 Problem: XPUB test broken on Windows since #1569
Solution:
- Adjust test_subscriptions() to support different protocol types
- Run TCP and IPC tests everywhere but on Windows and OpenVMS
2016-04-23 16:18:38 +01:00
hitstergtd
7f0e380c05 Problem: LD search path warnings if using Clang
Solution: PR #1906 did not solve this problem properly; subsequent Travis CI
indicated that the issue happens with Clang/LLVM, so make sure to fix the
issue by detecting if Cmake CMake is using Clang for building the tests.
2016-04-21 22:32:15 +01:00
Luca Boccassi
5178251587 Problem: test_ipc_wildcard is ran on Windows
Solution: move it to the unix-only section of Makefile.am and
tests/CMakeLists.txt since it uses Unix IPC sockets.
2016-04-21 14:17:10 +01:00
Doron Somech
d6a57ad589 Merge pull request #1912 from hitstergtd/hitstergtd-testsrcfd-win-fix
Problem: ZMQ_SRCFD test does not work on Windows
2016-04-21 15:38:05 +03:00
hitstergtd
e8aeb3686d Problem: ZMQ_SRCFD test does not work on Windows
Solution: add Winsock specific assertions, since getpeername() should will
return SOCKET_ERROR (-1) and WSAGetLastError() will be set to WSAENOTSOCK
2016-04-21 13:24:02 +01:00
Hitster GTD
99763cce41 Merge pull request #1909 from somdoron/master
problem: push-pull socket types are not thread safe
2016-04-21 12:54:04 +01:00
somdoron
e6dae56c6e Scatter-Gather socket types 2016-04-21 14:50:58 +03:00
Luca Boccassi
ea294afd8b Problem: CMake does not check for TIPC support
Solution: add macro in ZMQSourceRunChecks.cmake and optionally
include the TIPC sources if the support is available.
More importantly, only run the TIPC tests if the support is there.
2016-04-21 11:33:20 +01:00
hitstergtd
846b2ba174 Problem: Linker search path warnings on OS X
Problem:
A per-test Linker search path was added in commit a911fa4 to CMakeLists.txt as
part of fixing Windows builds. Whilst this is silently ignored by ld(1) on
Linux, it doesn't settle well with OS X. Spurious warnings are generated about
missing directories leading to convoluted build logs.

Solution:
Make per-Test LINK_DIRECTORIES() conditional for non-Apple platforms.
2016-04-19 12:38:16 +01:00
Luca Boccassi
c8211bf320 Problem: can't unbind with bound addr with IPv6
Solution: try to resolve the TCP endpoint passed by the user in the
zmq_unbind call before giving up, if it doesn't match.
This fixes a breakage in the API, where after a call to
zmq_bind(s, "tcp://127.0.0.1:9999") with IPv6 enabled on s would
result in the call to zmq_unbind(s, "tcp://127.0.0.1:9999") failing.
Add more test cases to increase coverage on all combinations of TCP
endpoints.
2016-04-18 18:43:36 +01:00
Luca Boccassi
ac0e97e5dc Problem: can't test if IPv6 is available in tests
Solution: add helper function is_ipv6_available to testutil.hpp to
test if IPv6 is available on the building platform.
This function will try to open and bind a socket to ::1:*, as it's
the ultimate way of knowing if, at least on the loopback, IPv6 is
enabled.
2016-04-18 18:43:36 +01:00
hitstergtd
e09eb0db6f Problem: comment not well formed in CMakeLists.txt
Solution: fix comment
2016-04-18 16:33:34 +01:00
hitstergtd
9a9bfb6443 Problem: test_udp does not release resources properly
Solution:
- call zmq_msg_close() if there is an error
- call free() to release resources if there is an error (CWE-404)
2016-04-18 14:44:54 +01:00
hitstergtd
307bd952bc Make all Linux-specific tests conditional
Move tests specific to Linux under a platform conditional thereby eliminating
unnecessary builds and fixing "make test" on Mac OS X and possibly other
non-Linux systems.

Tests specific to Linux:
    - abstract namespace support for AF_UNIX sockets
    - TIPC support (AF_TIPC)

Test success rate jumps from 90% to 100% on Mac OS X after this change.
2016-04-14 23:44:17 +01:00
Constantin Rack
3f77cf5a2f Merge pull request #1892 from bluca/solaris_fixes 2016-04-13 05:18:12 +02:00
Luca Boccassi
a01baba38b Problem: test_use_fd_tcp does not work on Solaris
Solution: pass a struct addrinfo hint to getaddrinfo with a hint
about the address family to avoid a failure.
2016-04-13 00:32:19 +01:00
Patrik Wenger
621c965fae Problem: tricky return value from zmq::socket_poller_t::wait when poller is empty
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.
2016-04-12 20:11:50 +02:00
Satyajit Padalkar
e3016b66bd Fix tests/test_many_sockets.cpp 2016-04-07 23:41:09 -04:00
Frederic Tregon
625b618776 Fixed ZMQ_REQ_CORRELATE (see pull request #1730)
Problem: Since pull request #1730 was merged, protocol for REQ socket is
checked at the session level and this check does not take into account
the possibility of a request_id being part of the message. Thus the option
ZMQ_REQ_CORRELATE would no longer work.
This is now fixed: the possiblity of a 4 bytes integer being present
before the delimiter frame is taken into account (whether or not this
breaks the REQ/REP RFC is another issue).
2016-04-02 18:36:29 +02:00
Frederic Tregon
e45dfe3bc7 Fixed issue #1695 (ZMQ_REQ_CORRELATE)
Problem: when using ZMQ_REQ_RELAXED + ZMQ_REQ_CORRELATE and two 'send' are
executed in a row and no server is available at the time of the sends,
then the internal request_id used to identify messages gets corrupted and
the two messages end up with the same request_id. The correlation no
longer works in that case and you may end up with the wrong message.

Solution: make a copy of the request_id instance member before sending it
down the pipe.
2016-03-20 20:38:18 +01:00
Pieter Hintjens
340eb52165 Merge pull request #1847 from bluca/test_large_msg
Problem: test_large_msg requires 2GB of free RAM
2016-03-18 09:41:42 +01:00
Pete LaDow
075de03d1c Use FILENAME_MAX to determine BUFSIZE when getting socket path. 2016-03-17 15:12:57 -07:00
Luca Boccassi
15fd419f22 Problem: test_large_msg requires 2GB of free RAM
Solution: remove temporarily until proper message limits have been
implemented, then a more granular test case can be added without
such high requirements which are problematic in embedded environment,
build systems, VMs and CI systems
2016-03-16 21:47:58 +00:00
Luca Boccassi
11917f850a Problem: IPC wildcard test broken on OSX
Solution: increase path buffer length to 73
2016-03-14 22:39:34 +00:00
Suudy
b6080a798c Updated handling of Unix Domain Sockets, make use of temporary directories, and cleanup afterward. Fix test_term_endpoint handling of optvallen 2016-03-14 12:17:49 -07:00
Osiris
cd1dfb4092 Problem: CMakelist missing support for Windows Precompiled headers
Solution: Add precompiled flags to CMakeList.txt for faster compiles
+ bonus - removed compilation warning on Windows by adding
	 add_definitions (-D_WINSOCK_DEPRECATED_NO_WARNINGS)
2016-03-06 06:23:26 -06:00
Osiris
1c9cec227d Problem: Tests do no build in Windows environment
Solution: Modified CMakelist.txt to build correctly for Windows
- corrected CMake required version to make sure it builds in
  Ubuntu 14.04 LTS with no warnings.
2016-03-05 14:01:21 -06:00
Osiris
a911fa41b8 Problem: Tests do no build in Windows environment
Solution: Modified CMakelist.txt to build correctly for Windows
2016-03-05 11:23:23 -06:00
Pieter Hintjens
5b7bf7509f Problem: can't be sure crypto_box always returns 0
Libsodium has started returning -1 in some cases.

Solution: allow and handle error returns from these calls.

Fixes #1831
2016-03-01 15:01:23 +01:00
Luca Boccassi
facb512105 Problem: SETTLE_TIME is too short on slow systems
Solution: increase SETTLE_TIME from 50ms to 300ms to avoid failing on
slower environments like through Valgrind on slow VMs.
2016-02-13 18:17:36 +00:00
Luca Boccassi
217f6c438e Problem: tests README does not document msleep
Solution: suggest to use the common approach of msleep (SETTLE_TIME)
after a connect if necessary, rather than reimplementing a different
way.
2016-02-13 18:04:25 +00:00
Luca Boccassi
706c3b7c4b Problem: test_shutdown_stress_tipc broken on OSX/Cmake
Solution: include pthread.h in testutil.hpp, removed from
test_shutdown_stress_tipc in an earlier commit
2016-02-13 18:01:03 +00:00
Luca Boccassi
cb41201880 Problem: various tests fail in slow environments
Solution: add msleep (SETTLE_TIME) to test_immediate, test_spec_rep
and test_spec_router after the sockets are created and connected to
avoid failing when running in slower environment like through
Valgrind in underpowered VMs.
2016-02-13 18:01:03 +00:00
Luca Boccassi
4a84f8a02e Problem: tests use various sleep patterns to wait
Solution: use msleep (SETTLE_TIME) everywhere when waiting for the
connections/sockets to be settled instead of a variety of patterns
and functions to make tests more coherent.
2016-02-13 18:01:03 +00:00
Luca Boccassi
955b51dfd2 Problem: test_msg_ffn uses unitialised memory
Solution: memset temporary buffer before use to reduce Valgrind noise
2016-02-13 16:28:48 +00:00
Luca Boccassi
240190131c Problem: test_srcfd uses unitialised memory
Solution: memset temporary buffer before use to reduce Valgrind noise
2016-02-13 15:39:30 +00:00
Luca Boccassi
302c7bee50 Problem: test_fork does not clean up at exit
Solution: close socket and destroy context to reduce Valgrind noise
2016-02-13 11:35:51 +00:00
Luca Boccassi
f87888f80c Problem: test_router_mandatory_hwm uses unitialised memory
Solution: memset temporary buffer before use to reduce Valgrind noise
2016-02-13 11:35:51 +00:00
Luca Boccassi
cffc653535 Problem: test_pre_allocated_fd_tcp leaks addrinfo
Solution: free addrinfo to reduce Valgrind noise
2016-02-13 11:35:51 +00:00
Luca Boccassi
05ad915265 Problem: test_term_endpoint does not clean up at exit
Solution: close socket and destroy context to reduce Valgrind noise
2016-02-13 11:35:51 +00:00
Luca Boccassi
f8f8043222 Problem: test_msg_ffn uses unitialised memory
Solution: pass correct size to memcmp to avoid reading uninitialised
areas of the buffer.
2016-02-13 11:35:51 +00:00
Luca Boccassi
e177512c82 Problem: test_system does not clean up at exit
Solution: close socket and destroy context to reduce Valgrind noise
2016-02-13 11:35:51 +00:00
Pieter Hintjens
9c0d176d68 Problem: tests don't build on Windows
There were numerous small issues with test cases:

- some lacked the right source file header
- some were not portable at all
- some were using internal libzmq APIs (headers)

Solution: fixed and cleaned up.
2016-02-12 16:12:44 +01:00
Pieter Hintjens
bbcc79d188 Problem: tests don't build on Windows
There were numerous small issues with test cases:

- some lacked the right source file header
- some were not portable at all
- some were using internal libzmq APIs (headers)

Solution: fixed and cleaned up.
2016-02-12 15:48:37 +01:00
Pieter Hintjens
06acd76a21 Problem: people don't know how to write test cases
Solution: document the minimum rules in README.md
2016-02-12 15:48:37 +01:00
Pieter Hintjens
8230c0d396 Problem: gyp does not build tests
Solution: it's a lot of work to define the tests in project.gyp
so I did this using gsl to generate the JSON, from a small XML
list of the test cases.

To keep this, and the hundreds of .mk files, away from the root
directory, I've moved the gyp files into builds/gyp, where you
would run them.

It all seems to work now. Next up, OS/X and Windows :)
2016-02-12 11:31:38 +01:00
Pieter Hintjens
b49a60410a Problem: use of libsodium vs. tweetnacl is confused
It's unclear which we need and in the source code, conditional code
treats tweetnacl as a subclass of libsodium, which is inaccurate.

Solution: redesign the configure/cmake API for this:

* tweetnacl is present by default and cannot be enabled
* libsodium can be enabled using --with-libsodium, which replaces
  the built-in tweetnacl
* CURVE encryption can be disabled entirely using --enable-curve=no

The macros we define in platform.hpp are:

    ZMQ_HAVE_CURVE    1        //  When CURVE is enabled
    HAVE_LIBSODIUM    1        //  When we are using libsodium
    HAVE_TWEETNACL    1        //  When we're using tweetnacl (default)

As of this patch, the default build of libzmq always has CURVE
security, and always uses tweetnacl.
2016-02-11 13:32:01 +01:00
Pieter Hintjens
62c66ae7f7 Problem: test_large_msg kills my system temporarily
And I'm on a reasonably sized laptop. I think allocating INT_MAX
memory is dangerous in a test case.

Solution: expose this as a context option. I've used ZMQ_MAX_MSGSZ
and documented it and implemented the API. However I don't know how
to get the parent context for a socket, so the code in zmq.cpp is
still unfinished.
2016-02-09 10:55:09 +01:00
Luca Boccassi
edc4ee03e8 Problem: ZMQ_USEFD does not follow conventions
Solution: rename socket option (and variables and files) from usefd
to use_fd.
2016-02-09 09:36:14 +00:00
Luca Boccassi
c158178798 Problem: ZMQ_PRE_ALLOCATED_FD is too long
Solution: rename socket option (and variables and files) from
pre_allocated_fd to usefd.
2016-02-08 22:46:34 +00:00
Pieter Hintjens
a1f51b695f Problem: unclear rules for passing null arguments
Solution: be more explicit in the code, and in the zmq_recv man
page (which is the most unobvious case). Assert if length is not
zero and buffer is nonetheless null.
2016-02-06 14:13:13 +01:00
Pieter Hintjens
c8318912f5 Problem: test case is using internal API
It is poor style for test cases to use the internal API (i.e.
libzmq classes or header files), as this code serves the purpose
of teaching developers how to use the library (it doesn't do this
very well, it's an ambition).

Also, including headers in src/ creates problems when compiling.

Solution: remove use of src/macros.hpp.
2016-02-06 14:12:43 +01:00
Michael
7270d4de65 windows.hpp needs to be included before zmq.h
windows.hpp must be included first due to increases _WIN32_WINNT version
2016-02-06 23:31:56 +11:00
Michael
d06314df84 added windows includes as well as unix includes
added conditional includes for unix / windows
2016-02-06 23:19:10 +11:00
Michael
75bea4bc13 update for mingw's default _WIN32_WINNT
mingw defaults with _WIN32_WINNT as 0x0502 which doesn't define inet_pton(), so add a conditional check
2016-02-06 23:03:12 +11:00
Michael
05b5633b8d update for mingw's default _WIN32_WINNT
mingw defaults with _WIN32_WINNT as 0x0502 which doesn't define inet_pton(), so add a conditional check
2016-02-06 23:01:26 +11:00
Michael
596fd2408a added ZMQ_HAVE_WINDOWS check to _WIN32_WINNT usage 2016-02-06 22:59:58 +11:00
Michael
b98b1495af added ZMQ_HAVE_WINDOWS check to _WIN32_WINNT usage 2016-02-06 22:59:13 +11:00
Michael
595181d301 added ZMQ_HAVE_WINDOWS check to _WIN32_WINNT usage 2016-02-06 22:58:38 +11:00
Luca Boccassi
84ad4bf0ff Problem: cannot use new pre-allocated FD with TCP
Solution: parse the value set by the ZMQ_PRE_ALLOCATED_FD sockopt
when creating a new TCP socket and use it if valid.
Add new tests/test_pre_allocated_fd_tcp.cpp unit test.
2016-02-04 16:57:26 +00:00
Luca Boccassi
9b885b7c00 Problem: cannot use new pre-allocated FD with IPC
Solution: parse the value set by the ZMQ_PRE_ALLOCATED_FD sockopt
when creating a new IPC socket and use it if valid.
Add new tests/test_pre_allocated_fd_ipc.cpp unit test.
2016-02-04 16:57:26 +00:00
Luca Boccassi
4bcbb3055e Problem: cannot use pre-allocated FDs. Fixes #777
Solution: add new [set|get]sockopt ZMQ_PRE_ALLOCATED_FD to allow
users to let ZMQ use a pre-allocated file descriptor instead of
allocating a new one. Update [set|get]sockopt documentation and
test accordingly.

The main use case for this feature is a socket-activated systemd
service. For more information about this feature see:
http://0pointer.de/blog/projects/socket-activation.html
2016-02-04 16:57:26 +00:00
Pieter Hintjens
44c6b0484e Revert "Revert "Problem: deprecated use and reference of zmq_term"" 2016-02-01 23:00:06 +01:00
Pieter Hintjens
1708bfefb7 Revert "Problem: deprecated use and reference of zmq_term" 2016-02-01 22:41:51 +01:00
Constantin Rack
0d171563d0 Problem: tests use deprecated zmq_term function
Solution: replace all occurrences with `zmq_ctx_term`
2016-02-01 21:40:24 +01:00
Constantin Rack
7da3ee138e Problem: deprecated zmq_utils.h is still included
Solution: remove all remaining references to `zmq_utils.h`
2016-02-01 11:34:36 +01:00
somdoron
389e853c6d Fix compilation errors on windows 2016-01-30 13:29:41 +02:00
Doron Somech
add4e7675f Merge pull request #1744 from jcfr/fix-gcc-warnings
Fix unused-parameter/unused-but-set-variable/missing-field-initializers warnings
2016-01-30 09:08:09 +01:00