diff --git a/tests/Makefile.am b/tests/Makefile.am index 329e378e..8c7b0bd7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -134,7 +134,7 @@ test_bind_src_address_SOURCES = test_bind_src_address.cpp test_metadata_SOURCES = test_metadata.cpp test_id2fd_SOURCES = test_id2fd.cpp test_capabilities_SOURCES = test_capabilities.cpp -test_xpub_wait_inproc_SOURCES = test_xpub_wait_inproc.cpp +test_xpub_nodrop_SOURCES = test_xpub_nodrop.cpp if !ON_MINGW test_shutdown_stress_SOURCES = test_shutdown_stress.cpp test_pair_ipc_SOURCES = test_pair_ipc.cpp testutil.hpp diff --git a/tests/test_xpub_nodrop.cpp b/tests/test_xpub_nodrop.cpp index 914d4f08..cc15e934 100644 --- a/tests/test_xpub_nodrop.cpp +++ b/tests/test_xpub_nodrop.cpp @@ -50,34 +50,33 @@ int main (void) rc = zmq_setsockopt (sub, ZMQ_SUBSCRIBE, "", 0); assert (rc == 0); - int hwmlimit = hwm-1; + int hwmlimit = hwm - 1; int send_count = 0; + // Send an empty message - for (int i = 0; i< hwmlimit; i++) { - rc = zmq_send (pub, NULL, 0, 0); - assert (rc == 0); - send_count++; + for (int i = 0; i < hwmlimit; i++) { + rc = zmq_send (pub, NULL, 0, 0); + assert (rc == 0); + send_count++; } int recv_count = 0; - do { - // Receive the message in the subscriber -// rc = zmq_recv (sub, buff, sizeof (buff), ZMQ_DONTWAIT); - rc = zmq_recv (sub, NULL, 0, ZMQ_DONTWAIT); - if( -1 == rc ) { - assert(EAGAIN == errno); - } - else - { - assert( 0 == rc ); - recv_count++; - } - } while( 0 == rc); + // Receive the message in the subscriber + rc = zmq_recv (sub, NULL, 0, ZMQ_DONTWAIT); + if (rc == -1) + assert (errno == EAGAIN); + else { + assert (rc == 0); + recv_count++; + } + } + while (rc == 0); - assert(send_count == recv_count); - // now test real blocking behavior - // set a timeout, default is infinite + assert (send_count == recv_count); + + // Now test real blocking behavior + // Set a timeout, default is infinite int timeout = 0; rc = zmq_setsockopt (pub, ZMQ_SNDTIMEO, &timeout, 4); assert (rc == 0); @@ -85,19 +84,15 @@ int main (void) send_count = 0; recv_count = 0; hwmlimit = hwm; - // Send an empty message - while( 0 == zmq_send (pub, NULL, 0, 0) ) - { - send_count++; - } - assert( EAGAIN == errno); + + // Send an empty message until we get an error, which must be EAGAIN + while (zmq_send (pub, "", 0, 0) == 0) + send_count++; + assert (errno == EAGAIN); - while( 0 == zmq_recv (sub, NULL, 0, ZMQ_DONTWAIT)) - { - recv_count ++; - } - - assert( send_count == recv_count); + while (zmq_recv (sub, NULL, 0, ZMQ_DONTWAIT) == 0) + recv_count++; + assert (send_count == recv_count); // Clean up. rc = zmq_close (pub);