Commit b29d46b6 authored by Luca Boccassi's avatar Luca Boccassi

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.
parent 5934919f
...@@ -37,12 +37,12 @@ int main (void) ...@@ -37,12 +37,12 @@ int main (void)
void *sb = zmq_socket (ctx, ZMQ_PAIR); void *sb = zmq_socket (ctx, ZMQ_PAIR);
assert (sb); assert (sb);
int rc = zmq_bind (sb, "ipc:///tmp/tester"); int rc = zmq_bind (sb, "ipc:///tmp/test_pair_ipc");
assert (rc == 0); assert (rc == 0);
void *sc = zmq_socket (ctx, ZMQ_PAIR); void *sc = zmq_socket (ctx, ZMQ_PAIR);
assert (sc); assert (sc);
rc = zmq_connect (sc, "ipc:///tmp/tester"); rc = zmq_connect (sc, "ipc:///tmp/test_pair_ipc");
assert (rc == 0); assert (rc == 0);
bounce (sb, sc); bounce (sb, sc);
......
/* /*
Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file Copyright (c) 2007-2017 Contributors as noted in the AUTHORS file
This file is part of libzmq, the ZeroMQ core engine in C++. This file is part of libzmq, the ZeroMQ core engine in C++.
...@@ -32,17 +32,21 @@ ...@@ -32,17 +32,21 @@
int main (void) int main (void)
{ {
setup_test_environment(); setup_test_environment();
char my_endpoint[256];
void *ctx = zmq_ctx_new (); void *ctx = zmq_ctx_new ();
assert (ctx); assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_REP); void *sb = zmq_socket (ctx, ZMQ_REP);
assert (sb); assert (sb);
int rc = zmq_bind (sb, "ipc:///tmp/tester"); int rc = zmq_bind (sb, "ipc://*");
assert (rc == 0);
size_t len = sizeof(my_endpoint);
rc = zmq_getsockopt (sb, ZMQ_LAST_ENDPOINT, my_endpoint, &len);
assert (rc == 0); assert (rc == 0);
void *sc = zmq_socket (ctx, ZMQ_REQ); void *sc = zmq_socket (ctx, ZMQ_REQ);
assert (sc); assert (sc);
rc = zmq_connect (sc, "ipc:///tmp/tester"); rc = zmq_connect (sc, my_endpoint);
assert (rc == 0); assert (rc == 0);
bounce (sb, sc); bounce (sb, sc);
......
...@@ -64,14 +64,14 @@ void test_req_rep () ...@@ -64,14 +64,14 @@ void test_req_rep ()
void *sb = zmq_socket (ctx, ZMQ_REP); void *sb = zmq_socket (ctx, ZMQ_REP);
assert (sb); assert (sb);
pre_allocate_sock(sb, "/tmp/tester"); pre_allocate_sock(sb, "/tmp/test_use_fd_ipc");
int rc = zmq_bind (sb, "ipc:///tmp/tester"); int rc = zmq_bind (sb, "ipc:///tmp/test_use_fd_ipc");
assert (rc == 0); assert (rc == 0);
void *sc = zmq_socket (ctx, ZMQ_REQ); void *sc = zmq_socket (ctx, ZMQ_REQ);
assert (sc); assert (sc);
rc = zmq_connect (sc, "ipc:///tmp/tester"); rc = zmq_connect (sc, "ipc:///tmp/test_use_fd_ipc");
assert (rc == 0); assert (rc == 0);
bounce (sb, sc); bounce (sb, sc);
...@@ -85,7 +85,7 @@ void test_req_rep () ...@@ -85,7 +85,7 @@ void test_req_rep ()
rc = zmq_ctx_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
rc = unlink ("/tmp/tester"); rc = unlink ("/tmp/test_use_fd_ipc");
assert (rc == 0); assert (rc == 0);
} }
...@@ -97,14 +97,14 @@ void test_pair () ...@@ -97,14 +97,14 @@ void test_pair ()
void *sb = zmq_socket (ctx, ZMQ_PAIR); void *sb = zmq_socket (ctx, ZMQ_PAIR);
assert (sb); assert (sb);
pre_allocate_sock(sb, "/tmp/tester"); pre_allocate_sock(sb, "/tmp/test_use_fd_ipc");
int rc = zmq_bind (sb, "ipc:///tmp/tester"); int rc = zmq_bind (sb, "ipc:///tmp/test_use_fd_ipc");
assert (rc == 0); assert (rc == 0);
void *sc = zmq_socket (ctx, ZMQ_PAIR); void *sc = zmq_socket (ctx, ZMQ_PAIR);
assert (sc); assert (sc);
rc = zmq_connect (sc, "ipc:///tmp/tester"); rc = zmq_connect (sc, "ipc:///tmp/test_use_fd_ipc");
assert (rc == 0); assert (rc == 0);
bounce (sb, sc); bounce (sb, sc);
...@@ -118,7 +118,7 @@ void test_pair () ...@@ -118,7 +118,7 @@ void test_pair ()
rc = zmq_ctx_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
rc = unlink ("/tmp/tester"); rc = unlink ("/tmp/test_use_fd_ipc");
assert (rc == 0); assert (rc == 0);
} }
...@@ -131,14 +131,14 @@ void test_client_server () ...@@ -131,14 +131,14 @@ void test_client_server ()
void *sb = zmq_socket (ctx, ZMQ_SERVER); void *sb = zmq_socket (ctx, ZMQ_SERVER);
assert (sb); assert (sb);
pre_allocate_sock(sb, "/tmp/tester"); pre_allocate_sock(sb, "/tmp/test_use_fd_ipc");
int rc = zmq_bind (sb, "ipc:///tmp/tester"); int rc = zmq_bind (sb, "ipc:///tmp/test_use_fd_ipc");
assert (rc == 0); assert (rc == 0);
void *sc = zmq_socket (ctx, ZMQ_CLIENT); void *sc = zmq_socket (ctx, ZMQ_CLIENT);
assert (sc); assert (sc);
rc = zmq_connect (sc, "ipc:///tmp/tester"); rc = zmq_connect (sc, "ipc:///tmp/test_use_fd_ipc");
assert (rc == 0); assert (rc == 0);
zmq_msg_t msg; zmq_msg_t msg;
...@@ -199,7 +199,7 @@ void test_client_server () ...@@ -199,7 +199,7 @@ void test_client_server ()
rc = zmq_ctx_term (ctx); rc = zmq_ctx_term (ctx);
assert (rc == 0); assert (rc == 0);
rc = unlink ("/tmp/tester"); rc = unlink ("/tmp/test_use_fd_ipc");
assert (rc == 0); assert (rc == 0);
#endif #endif
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment