mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-27 15:41:05 +08:00
Problem: test_filter_ipc is flacky
Solution: expect send failure and use random endpoint
This commit is contained in:
parent
ccdc2f7583
commit
bd0a34899a
@ -41,8 +41,10 @@ static void bounce_fail (void *server_, void *client_)
|
|||||||
char buffer[32];
|
char buffer[32];
|
||||||
|
|
||||||
// Send message from client to server
|
// Send message from client to server
|
||||||
send_string_expect_success (client_, content, ZMQ_SNDMORE);
|
int rc = zmq_send (client_, content, 32, ZMQ_SNDMORE);
|
||||||
send_string_expect_success (client_, content, 0);
|
TEST_ASSERT_TRUE (rc == 32 || rc == -1);
|
||||||
|
rc = zmq_send (client_, content, 32, 0);
|
||||||
|
TEST_ASSERT_TRUE (rc == 32 || rc == -1);
|
||||||
|
|
||||||
// Receive message at server side (should not succeed)
|
// Receive message at server side (should not succeed)
|
||||||
int timeout = SETTLE_TIME;
|
int timeout = SETTLE_TIME;
|
||||||
@ -61,7 +63,7 @@ template <class T>
|
|||||||
static void
|
static void
|
||||||
run_test (int opt_, T optval_, int expected_error_, int bounce_test_)
|
run_test (int opt_, T optval_, int expected_error_, int bounce_test_)
|
||||||
{
|
{
|
||||||
void *sb = test_context_socket (ZMQ_DEALER);
|
void *sb = test_context_socket (ZMQ_PAIR);
|
||||||
|
|
||||||
if (opt_) {
|
if (opt_) {
|
||||||
const int rc = zmq_setsockopt (sb, opt_, &optval_, sizeof (optval_));
|
const int rc = zmq_setsockopt (sb, opt_, &optval_, sizeof (optval_));
|
||||||
@ -72,7 +74,7 @@ run_test (int opt_, T optval_, int expected_error_, int bounce_test_)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *sc = test_context_socket (ZMQ_DEALER);
|
void *sc = test_context_socket (ZMQ_PAIR);
|
||||||
|
|
||||||
// If a test fails, don't hang for too long
|
// If a test fails, don't hang for too long
|
||||||
int timeout = 2500;
|
int timeout = 2500;
|
||||||
@ -89,9 +91,9 @@ run_test (int opt_, T optval_, int expected_error_, int bounce_test_)
|
|||||||
zmq_setsockopt (sc, ZMQ_RECONNECT_IVL, &interval, sizeof (int)));
|
zmq_setsockopt (sc, ZMQ_RECONNECT_IVL, &interval, sizeof (int)));
|
||||||
|
|
||||||
if (bounce_test_) {
|
if (bounce_test_) {
|
||||||
const char *endpoint = "ipc://test_filter_ipc.sock";
|
char my_endpoint[256];
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, endpoint));
|
bind_loopback_ipc (sb, my_endpoint, sizeof my_endpoint);
|
||||||
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, endpoint));
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, my_endpoint));
|
||||||
|
|
||||||
if (bounce_test_ > 0)
|
if (bounce_test_ > 0)
|
||||||
bounce (sb, sc);
|
bounce (sb, sc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user