From f5eebc2ae3935ce8b206233eb0f62ba2560f19d3 Mon Sep 17 00:00:00 2001 From: Richard Newton Date: Mon, 17 Mar 2014 13:41:02 +0000 Subject: [PATCH] Remove delays and destroy/recreate context between tests --- tests/test_connect_rid.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/test_connect_rid.cpp b/tests/test_connect_rid.cpp index 361ca648..23e493b9 100644 --- a/tests/test_connect_rid.cpp +++ b/tests/test_connect_rid.cpp @@ -20,16 +20,17 @@ #include "testutil.hpp" -void test_stream_2_stream(void* ctx_){ +void test_stream_2_stream(){ void *rbind, *rconn1; int ret; char buff[256]; char msg[] = "hi 1"; const char *bindip = "tcp://127.0.0.1:5556"; int zero = 0; + void *ctx = zmq_ctx_new (); // Set up listener STREAM. - rbind = zmq_socket (ctx_, ZMQ_STREAM); + rbind = zmq_socket (ctx, ZMQ_STREAM); assert (rbind); ret = zmq_setsockopt (rbind, ZMQ_LINGER, &zero, sizeof (zero)); assert (0 == ret); @@ -37,7 +38,7 @@ void test_stream_2_stream(void* ctx_){ assert(0 == ret); // Set up connection stream. - rconn1 = zmq_socket (ctx_, ZMQ_STREAM); + rconn1 = zmq_socket (ctx, ZMQ_STREAM); assert (rconn1); ret = zmq_setsockopt (rconn1, ZMQ_LINGER, &zero, sizeof (zero)); assert (0 == ret); @@ -81,15 +82,18 @@ void test_stream_2_stream(void* ctx_){ assert(0 == ret); ret = zmq_close (rconn1); assert(0 == ret); + + zmq_ctx_destroy (ctx); } -void test_router_2_router(void* ctx,bool named){ +void test_router_2_router(bool named){ void *rbind, *rconn1; int ret; char buff[256]; char msg[] = "hi 1"; const char *bindip = "tcp://127.0.0.1:5556"; int zero = 0; + void *ctx = zmq_ctx_new (); // Create bind socket. rbind = zmq_socket (ctx, ZMQ_ROUTER); @@ -164,21 +168,17 @@ void test_router_2_router(void* ctx,bool named){ assert(0 == ret); ret = zmq_close (rconn1); assert(0 == ret); + + zmq_ctx_destroy (ctx); } int main (void) { - void *ctx; setup_test_environment (); - ctx = zmq_ctx_new (); - assert (ctx); - test_stream_2_stream (ctx); - msleep(100); // Give time for bound socket to be closed. - test_router_2_router (ctx, false); - msleep(100); // Give time for bound socket to be closed. - test_router_2_router (ctx, true); - zmq_ctx_destroy (ctx); - printf ("'test_connect_rid' passed"); + + test_stream_2_stream (); + test_router_2_router (false); + test_router_2_router (true); + return 0; } -