summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-11-01 13:39:54 +0100
committerMartin Sustrik <sustrik@250bpm.com>2011-11-01 13:39:54 +0100
commit7842c7107358324e8c5b9af7272e6dcab8c97931 (patch)
treed97f0e869ea0d95c60d41c96b48627c38e9c464c /tests
parent626099aa2a292178872843c55cc5226e6850f2ed (diff)
LABELS and COMMANDs removed
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/test_invalid_rep.cpp13
-rw-r--r--tests/test_reqrep_device.cpp31
-rw-r--r--tests/test_reqrep_drop.cpp144
4 files changed, 12 insertions, 178 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6ed3762..5f0cfc1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -7,7 +7,6 @@ noinst_PROGRAMS = test_pair_inproc \
test_reqrep_tcp \
test_hwm \
test_reqrep_device \
- test_reqrep_drop \
test_sub_forward \
test_invalid_rep
@@ -24,7 +23,6 @@ test_reqrep_inproc_SOURCES = test_reqrep_inproc.cpp testutil.hpp
test_reqrep_tcp_SOURCES = test_reqrep_tcp.cpp testutil.hpp
test_hwm_SOURCES = test_hwm.cpp
test_reqrep_device_SOURCES = test_reqrep_device.cpp
-test_reqrep_drop_SOURCES = test_reqrep_drop.cpp
test_sub_forward_SOURCES = test_sub_forward.cpp
test_invalid_rep_SOURCES = test_invalid_rep.cpp
diff --git a/tests/test_invalid_rep.cpp b/tests/test_invalid_rep.cpp
index dc902c2..f158b05 100644
--- a/tests/test_invalid_rep.cpp
+++ b/tests/test_invalid_rep.cpp
@@ -1,6 +1,7 @@
/*
Copyright (c) 2009-2011 250bpm s.r.o.
Copyright (c) 2007-2011 iMatix Corporation
+ Copyright (c) 2011 VMware, Inc.
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -47,12 +48,12 @@ int main (int argc, char *argv [])
// Receive the request.
char addr [4];
- char seqn [4];
+ char bottom [1];
char body [1];
rc = zmq_recv (xrep_socket, addr, sizeof (addr), 0);
assert (rc == 4);
- rc = zmq_recv (xrep_socket, seqn, sizeof (seqn), 0);
- assert (rc == 4);
+ rc = zmq_recv (xrep_socket, bottom, sizeof (bottom), 0);
+ assert (rc == 0);
rc = zmq_recv (xrep_socket, body, sizeof (body), 0);
assert (rc == 1);
@@ -61,10 +62,10 @@ int main (int argc, char *argv [])
assert (rc == 4);
// Send valid reply.
- rc = zmq_send (xrep_socket, addr, 4, ZMQ_SNDLABEL);
- assert (rc == 4);
- rc = zmq_send (xrep_socket, seqn, 4, ZMQ_SNDLABEL);
+ rc = zmq_send (xrep_socket, addr, 4, ZMQ_SNDMORE);
assert (rc == 4);
+ rc = zmq_send (xrep_socket, bottom, 0, ZMQ_SNDMORE);
+ assert (rc == 0);
rc = zmq_send (xrep_socket, "b", 1, 0);
assert (rc == 1);
diff --git a/tests/test_reqrep_device.cpp b/tests/test_reqrep_device.cpp
index a451956..4ee7cf2 100644
--- a/tests/test_reqrep_device.cpp
+++ b/tests/test_reqrep_device.cpp
@@ -1,6 +1,7 @@
/*
Copyright (c) 2009-2011 250bpm s.r.o.
Copyright (c) 2007-2011 iMatix Corporation
+ Copyright (c) 2011 VMware, Inc.
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -64,15 +65,11 @@ int main (int argc, char *argv [])
assert (rc == 0);
rc = zmq_recvmsg (xrep, &msg, 0);
assert (rc >= 0);
- int rcvlabel;
- size_t sz = sizeof (rcvlabel);
- rc = zmq_getsockopt (xrep, ZMQ_RCVLABEL, &rcvlabel, &sz);
- assert (rc == 0);
int rcvmore;
+ size_t sz = sizeof (rcvmore);
rc = zmq_getsockopt (xrep, ZMQ_RCVMORE, &rcvmore, &sz);
assert (rc == 0);
- rc = zmq_sendmsg (xreq, &msg,
- (rcvlabel ? ZMQ_SNDLABEL : 0) | (rcvmore ? ZMQ_SNDMORE : 0));
+ rc = zmq_sendmsg (xreq, &msg, rcvmore ? ZMQ_SNDMORE : 0);
assert (rc >= 0);
}
@@ -81,21 +78,14 @@ int main (int argc, char *argv [])
rc = zmq_recv (rep, buff, 3, 0);
assert (rc == 3);
assert (memcmp (buff, "ABC", 3) == 0);
- int rcvlabel;
- size_t sz = sizeof (rcvlabel);
- rc = zmq_getsockopt (rep, ZMQ_RCVLABEL, &rcvlabel, &sz);
- assert (rc == 0);
- assert (!rcvlabel);
int rcvmore;
+ size_t sz = sizeof (rcvmore);
rc = zmq_getsockopt (rep, ZMQ_RCVMORE, &rcvmore, &sz);
assert (rc == 0);
assert (rcvmore);
rc = zmq_recv (rep, buff, 3, 0);
assert (rc == 3);
assert (memcmp (buff, "DEF", 3) == 0);
- rc = zmq_getsockopt (rep, ZMQ_RCVLABEL, &rcvlabel, &sz);
- assert (rc == 0);
- assert (!rcvlabel);
rc = zmq_getsockopt (rep, ZMQ_RCVMORE, &rcvmore, &sz);
assert (rc == 0);
assert (!rcvmore);
@@ -113,15 +103,10 @@ int main (int argc, char *argv [])
assert (rc == 0);
rc = zmq_recvmsg (xreq, &msg, 0);
assert (rc >= 0);
- int rcvlabel;
- size_t sz = sizeof (rcvlabel);
- rc = zmq_getsockopt (xreq, ZMQ_RCVLABEL, &rcvlabel, &sz);
- assert (rc == 0);
int rcvmore;
rc = zmq_getsockopt (xreq, ZMQ_RCVMORE, &rcvmore, &sz);
assert (rc == 0);
- rc = zmq_sendmsg (xrep, &msg,
- (rcvlabel ? ZMQ_SNDLABEL : 0) | (rcvmore ? ZMQ_SNDMORE : 0));
+ rc = zmq_sendmsg (xrep, &msg, rcvmore ? ZMQ_SNDMORE : 0);
assert (rc >= 0);
}
@@ -129,18 +114,12 @@ int main (int argc, char *argv [])
rc = zmq_recv (req, buff, 3, 0);
assert (rc == 3);
assert (memcmp (buff, "GHI", 3) == 0);
- rc = zmq_getsockopt (req, ZMQ_RCVLABEL, &rcvlabel, &sz);
- assert (rc == 0);
- assert (!rcvlabel);
rc = zmq_getsockopt (req, ZMQ_RCVMORE, &rcvmore, &sz);
assert (rc == 0);
assert (rcvmore);
rc = zmq_recv (req, buff, 3, 0);
assert (rc == 3);
assert (memcmp (buff, "JKL", 3) == 0);
- rc = zmq_getsockopt (req, ZMQ_RCVLABEL, &rcvlabel, &sz);
- assert (rc == 0);
- assert (!rcvlabel);
rc = zmq_getsockopt (req, ZMQ_RCVMORE, &rcvmore, &sz);
assert (rc == 0);
assert (!rcvmore);
diff --git a/tests/test_reqrep_drop.cpp b/tests/test_reqrep_drop.cpp
deleted file mode 100644
index 2829f5f..0000000
--- a/tests/test_reqrep_drop.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- Copyright (c) 2009-2011 250bpm s.r.o.
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
-
- This file is part of 0MQ.
-
- 0MQ is free software; you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- 0MQ is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <assert.h>
-
-#include "../include/zmq.h"
-#include "../include/zmq_utils.h"
-
-int main (int argc, char *argv [])
-{
- void *ctx = zmq_init (1);
- assert (ctx);
-
- // Check whether requests are discarded because of disconnected requester.
-
- // Create a server.
- void *xrep = zmq_socket (ctx, ZMQ_XREP);
- assert (xrep);
- int rc = zmq_bind (xrep, "tcp://127.0.0.1:5560");
- assert (rc == 0);
-
- // Create a client.
- void *xreq = zmq_socket (ctx, ZMQ_XREQ);
- assert (xreq);
- rc = zmq_connect (xreq, "tcp://127.0.0.1:5560");
- assert (rc == 0);
-
- // Send requests.
- rc = zmq_send (xreq, "ABC", 3, 0);
- assert (rc == 3);
- rc = zmq_send (xreq, "DEF", 3, 0);
- assert (rc == 3);
-
- // Disconnect client.
- rc = zmq_close (xreq);
- assert (rc == 0);
-
- // Wait a while for disconnect to happen.
- zmq_sleep (1);
-
- // Try to receive a request -- it should have been discarded.
- char buff [3];
- rc = zmq_recv (xrep, buff, 3, ZMQ_DONTWAIT);
- assert (rc < 0);
- assert (errno == EAGAIN);
-
- // Clean up.
- rc = zmq_close (xrep);
- assert (rc == 0);
-
- // New test. Check whether reply is dropped because of HWM overflow.
-
- int one = 1;
- xreq = zmq_socket (ctx, ZMQ_XREQ);
- assert (xreq);
- rc = zmq_setsockopt (xreq, ZMQ_RCVHWM, &one, sizeof(one));
- assert (rc == 0);
- rc = zmq_bind (xreq, "inproc://a");
- assert (rc == 0);
-
- void *rep = zmq_socket (ctx, ZMQ_REP);
- assert (rep);
- rc = zmq_setsockopt (rep, ZMQ_SNDHWM, &one, sizeof(one));
- assert (rc == 0);
- rc = zmq_connect (rep, "inproc://a");
- assert (rc == 0);
-
- // Send request 1
- rc = zmq_send (xreq, buff, 1, 0);
- assert (rc == 1);
-
- // Send request 2
- rc = zmq_send (xreq, buff, 1, 0);
- assert (rc == 1);
-
- // Receive request 1
- rc = zmq_recv (rep, buff, 1, 0);
- assert (rc == 1);
-
- // Send request 3
- rc = zmq_send (xreq, buff, 1, 0);
- assert (rc == 1);
-
- // Send reply 1
- rc = zmq_send (rep, buff, 1, 0);
- assert (rc == 1);
-
- // Receive request 2
- rc = zmq_recv (rep, buff, 1, 0);
- assert (rc == 1);
-
- // Send reply 2
- rc = zmq_send (rep, buff, 1, 0);
- assert (rc == 1);
-
- // Receive request 3
- rc = zmq_recv (rep, buff, 1, 0);
- assert (rc == 1);
-
- // Send reply 3
- rc = zmq_send (rep, buff, 1, 0);
- assert (rc == 1);
-
- // Receive reply 1
- rc = zmq_recv (xreq, buff, 1, 0);
- assert (rc == 1);
-
- // Receive reply 2
- rc = zmq_recv (xreq, buff, 1, 0);
- assert (rc == 1);
-
- // Try to receive reply 3, it should have been dropped.
- rc = zmq_recv (xreq, buff, 1, ZMQ_DONTWAIT);
- assert (rc == -1 && errno == EAGAIN);
-
- // Clean up.
- rc = zmq_close (xreq);
- assert (rc == 0);
- rc = zmq_close (rep);
- assert (rc == 0);
-
- rc = zmq_term (ctx);
- assert (rc == 0);
-
- return 0 ;
-}