mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-12 18:40:27 +01:00
Problem: test_reqrep_tcp does not test multiple endpoints
Solution: add a test for this use case
This commit is contained in:
parent
75219e33a7
commit
896192ff42
@ -62,11 +62,82 @@ void test_single_connect_ipv4 (void)
|
||||
assert (rc == 0);
|
||||
}
|
||||
|
||||
void test_multi_connect_ipv4 (void)
|
||||
{
|
||||
void *ctx = zmq_ctx_new ();
|
||||
assert (ctx);
|
||||
|
||||
void *sb0 = zmq_socket (ctx, ZMQ_REP);
|
||||
assert (sb0);
|
||||
int rc = zmq_bind (sb0, "tcp://127.0.0.1:5560");
|
||||
assert (rc == 0);
|
||||
|
||||
void *sb1 = zmq_socket (ctx, ZMQ_REP);
|
||||
assert (sb1);
|
||||
rc = zmq_bind (sb1, "tcp://127.0.0.1:5561");
|
||||
assert (rc == 0);
|
||||
|
||||
void *sb2 = zmq_socket (ctx, ZMQ_REP);
|
||||
assert (sb2);
|
||||
rc = zmq_bind (sb2, "tcp://127.0.0.1:5562");
|
||||
assert (rc == 0);
|
||||
|
||||
void *sc = zmq_socket (ctx, ZMQ_REQ);
|
||||
assert (sc);
|
||||
rc = zmq_connect (sc, "tcp://127.0.0.1:5560");
|
||||
assert (rc == 0);
|
||||
rc = zmq_connect (sc, "tcp://127.0.0.1:5561");
|
||||
assert (rc == 0);
|
||||
rc = zmq_connect (sc, "tcp://127.0.0.1:5562");
|
||||
assert (rc == 0);
|
||||
|
||||
bounce (sb0, sc);
|
||||
bounce (sb1, sc);
|
||||
bounce (sb2, sc);
|
||||
bounce (sb0, sc);
|
||||
bounce (sb1, sc);
|
||||
bounce (sb2, sc);
|
||||
bounce (sb0, sc);
|
||||
|
||||
rc = zmq_disconnect (sc, "tcp://127.0.0.1:5560");
|
||||
assert (rc == 0);
|
||||
rc = zmq_disconnect (sc, "tcp://127.0.0.1:5562");
|
||||
assert (rc == 0);
|
||||
rc = zmq_disconnect (sc, "tcp://127.0.0.1:5561");
|
||||
assert (rc == 0);
|
||||
|
||||
rc = zmq_unbind (sb0, "tcp://127.0.0.1:5560");
|
||||
assert (rc == 0);
|
||||
|
||||
rc = zmq_unbind (sb1, "tcp://127.0.0.1:5561");
|
||||
assert (rc == 0);
|
||||
|
||||
rc = zmq_unbind (sb2, "tcp://127.0.0.1:5562");
|
||||
assert (rc == 0);
|
||||
|
||||
rc = zmq_close (sc);
|
||||
assert (rc == 0);
|
||||
|
||||
rc = zmq_close (sb0);
|
||||
assert (rc == 0);
|
||||
|
||||
rc = zmq_close (sb1);
|
||||
assert (rc == 0);
|
||||
|
||||
rc = zmq_close (sb2);
|
||||
assert (rc == 0);
|
||||
|
||||
rc = zmq_ctx_term (ctx);
|
||||
assert (rc == 0);
|
||||
}
|
||||
|
||||
int main (void)
|
||||
{
|
||||
setup_test_environment ();
|
||||
|
||||
test_single_connect_ipv4 ();
|
||||
|
||||
test_multi_connect_ipv4 ();
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user