Hi!

Another patch which makes the first one usable. :)

License is MIT/X11.

>From 93d4380c545bf75ee059db4c9212a967df4f84c5 Mon Sep 17 00:00:00 2001
From: guidog <[email protected]>
Date: Fri, 27 Aug 2010 21:33:02 +0200
Subject: [PATCH] Fixed socket states in tests.

---
 tests/test_pair.cpp   |    3 +++
 tests/test_reqrep.cpp |    3 +++
 tests/testutil.hpp    |    6 +++++-
 3 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/tests/test_pair.cpp b/tests/test_pair.cpp
index 01ea5b0..381874f 100644
--- a/tests/test_pair.cpp
+++ b/tests/test_pair.cpp
@@ -39,6 +39,9 @@ int main ()
     {
         const string returned = zmqtestutil::ping_pong (p, expect);
         assert (expect == returned);
+        //  Adjust socket state so that poll shows only 1 pending message.
+        zmq::message_t mx ;
+        p.first->recv(&mx, 0);
     }
 
     {
diff --git a/tests/test_reqrep.cpp b/tests/test_reqrep.cpp
index 7fa976e..f33b4b5 100644
--- a/tests/test_reqrep.cpp
+++ b/tests/test_reqrep.cpp
@@ -39,6 +39,9 @@ int main()
     {
         const string returned = zmqtestutil::ping_pong (p, expect);
         assert (expect == returned);
+        //  Adjust socket state, so that first is clean for another send.
+        zmq::message_t mx ;
+        p.first->recv(&mx, 0);
     }
 
     {
diff --git a/tests/testutil.hpp b/tests/testutil.hpp
index 7c0a127..3e9f954 100644
--- a/tests/testutil.hpp
+++ b/tests/testutil.hpp
@@ -55,8 +55,12 @@ namespace zmqtestutil
         zmq::message_t pong;
         s2.recv (&pong, 0);
 
+        //  Send message via s2, so state is clean in case of req/rep.
+        std::string ret((char *)pong.data(), pong.size());
+        s2.send(pong, 0);
+
         //  Return received data as std::string.
-        return std::string ((char*) pong.data(), pong.size());
+        return ret ;
     }
 
 }
-- 
1.7.1

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to