summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/test_hwm.cpp7
-rw-r--r--tests/test_invalid_rep.cpp33
-rw-r--r--tests/test_pair_inproc.cpp7
-rw-r--r--tests/test_pair_ipc.cpp7
-rw-r--r--tests/test_pair_tcp.cpp8
-rw-r--r--tests/test_reqrep_device.cpp38
-rw-r--r--tests/test_reqrep_drop.cpp143
-rw-r--r--tests/test_reqrep_inproc.cpp7
-rw-r--r--tests/test_reqrep_ipc.cpp7
-rw-r--r--tests/test_reqrep_tcp.cpp8
-rw-r--r--tests/test_shutdown_stress.cpp8
-rw-r--r--tests/test_sub_forward.cpp8
-rw-r--r--tests/test_timeo.cpp7
-rw-r--r--tests/testutil.hpp1
15 files changed, 84 insertions, 207 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_hwm.cpp b/tests/test_hwm.cpp
index 10b26e1..d887b31 100644
--- a/tests/test_hwm.cpp
+++ b/tests/test_hwm.cpp
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
+ Copyright (c) 2010-2011 250bpm s.r.o.
+ Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -20,11 +20,14 @@
#include <assert.h>
+#include <stdio.h>
#include "testutil.hpp"
int main (int argc, char *argv [])
{
+ fprintf (stderr, "test_hwm running...\n");
+
void *ctx = zmq_init (1);
assert (ctx);
diff --git a/tests/test_invalid_rep.cpp b/tests/test_invalid_rep.cpp
index 2657c20..9c77cc4 100644
--- a/tests/test_invalid_rep.cpp
+++ b/tests/test_invalid_rep.cpp
@@ -1,6 +1,7 @@
/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
+ Copyright (c) 2010-2011 250bpm s.r.o.
+ Copyright (c) 2011 VMware, Inc.
+ Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -20,9 +21,12 @@
#include "../include/zmq.h"
#include <assert.h>
+#include <stdio.h>
int main (int argc, char *argv [])
{
+ fprintf (stderr, "test_invalid_rep running...\n");
+
// Create REQ/XREP wiring.
void *ctx = zmq_init (1);
assert (ctx);
@@ -45,25 +49,26 @@ int main (int argc, char *argv [])
assert (rc == 1);
// Receive the request.
- char addr [4];
- char seqn [4];
+ char addr [32];
+ int addr_size;
+ 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);
+ addr_size = zmq_recv (xrep_socket, addr, sizeof (addr), 0);
+ assert (addr_size >= 0);
+ rc = zmq_recv (xrep_socket, bottom, sizeof (bottom), 0);
+ assert (rc == 0);
rc = zmq_recv (xrep_socket, body, sizeof (body), 0);
assert (rc == 1);
// Send invalid reply.
- rc = zmq_send (xrep_socket, addr, 4, 0);
- assert (rc == 4);
+ rc = zmq_send (xrep_socket, addr, addr_size, 0);
+ assert (rc == addr_size);
// Send valid reply.
- rc = zmq_send (xrep_socket, addr, 4, ZMQ_SNDLABEL);
- assert (rc == 4);
- rc = zmq_send (xrep_socket, seqn, 4, ZMQ_SNDLABEL);
- assert (rc == 4);
+ rc = zmq_send (xrep_socket, addr, addr_size, ZMQ_SNDMORE);
+ assert (rc == addr_size);
+ 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_pair_inproc.cpp b/tests/test_pair_inproc.cpp
index 6194f2a..6705cc5 100644
--- a/tests/test_pair_inproc.cpp
+++ b/tests/test_pair_inproc.cpp
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
+ Copyright (c) 2010-2011 250bpm s.r.o.
+ Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -19,10 +19,13 @@
*/
#include <assert.h>
+#include <stdio.h>
#include "testutil.hpp"
int main (int argc, char *argv [])
{
+ fprintf (stderr, "test_pair_inproc running...\n");
+
void *ctx = zmq_init (0);
assert (ctx);
diff --git a/tests/test_pair_ipc.cpp b/tests/test_pair_ipc.cpp
index 2c83a69..96a265f 100644
--- a/tests/test_pair_ipc.cpp
+++ b/tests/test_pair_ipc.cpp
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
+ Copyright (c) 2010-2011 250bpm s.r.o.
+ Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -19,10 +19,13 @@
*/
#include <assert.h>
+#include <stdio.h>
#include "testutil.hpp"
int main (int argc, char *argv [])
{
+ fprintf (stderr, "test_pair_ipc running...\n");
+
void *ctx = zmq_init (1);
assert (ctx);
diff --git a/tests/test_pair_tcp.cpp b/tests/test_pair_tcp.cpp
index 8ecfef5..464be5a 100644
--- a/tests/test_pair_tcp.cpp
+++ b/tests/test_pair_tcp.cpp
@@ -1,6 +1,7 @@
/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
+ Copyright (c) 2010-2011 250bpm s.r.o.
+ Copyright (c) 2011 iMatix Corporation
+ Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -19,10 +20,13 @@
*/
#include <assert.h>
+#include <stdio.h>
#include "testutil.hpp"
int main (int argc, char *argv [])
{
+ fprintf (stderr, "test_pair_tcp running...\n");
+
void *ctx = zmq_init (1);
assert (ctx);
diff --git a/tests/test_reqrep_device.cpp b/tests/test_reqrep_device.cpp
index f6f06c9..d861cec 100644
--- a/tests/test_reqrep_device.cpp
+++ b/tests/test_reqrep_device.cpp
@@ -1,6 +1,7 @@
/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
+ Copyright (c) 2010-2011 250bpm s.r.o.
+ Copyright (c) 2011 VMware, Inc.
+ Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -20,11 +21,14 @@
#include <assert.h>
#include <string.h>
+#include <stdio.h>
#include "../include/zmq.h"
int main (int argc, char *argv [])
{
+ fprintf (stderr, "test_reqrep_device running...\n");
+
void *ctx = zmq_init (1);
assert (ctx);
@@ -63,15 +67,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);
}
@@ -80,21 +80,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);
@@ -112,15 +105,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);
}
@@ -128,18 +116,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 6531357..0000000
--- a/tests/test_reqrep_drop.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- 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 ;
-}
diff --git a/tests/test_reqrep_inproc.cpp b/tests/test_reqrep_inproc.cpp
index aeff7ef..f710968 100644
--- a/tests/test_reqrep_inproc.cpp
+++ b/tests/test_reqrep_inproc.cpp
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
+ Copyright (c) 2010-2011 250bpm s.r.o.
+ Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -19,10 +19,13 @@
*/
#include <assert.h>
+#include <stdio.h>
#include "testutil.hpp"
int main (int argc, char *argv [])
{
+ fprintf (stderr, "test_reqrep_inproc running...\n");
+
void *ctx = zmq_init (0);
assert (ctx);
diff --git a/tests/test_reqrep_ipc.cpp b/tests/test_reqrep_ipc.cpp
index af15998..fd9b28d 100644
--- a/tests/test_reqrep_ipc.cpp
+++ b/tests/test_reqrep_ipc.cpp
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
+ Copyright (c) 2010-2011 250bpm s.r.o.
+ Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -19,10 +19,13 @@
*/
#include <assert.h>
+#include <stdio.h>
#include "testutil.hpp"
int main (int argc, char *argv [])
{
+ fprintf (stderr, "test_reqrep_ipc running...\n");
+
void *ctx = zmq_init (1);
assert (ctx);
diff --git a/tests/test_reqrep_tcp.cpp b/tests/test_reqrep_tcp.cpp
index c713e26..1e6bbbb 100644
--- a/tests/test_reqrep_tcp.cpp
+++ b/tests/test_reqrep_tcp.cpp
@@ -1,6 +1,7 @@
/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
+ Copyright (c) 2010-2011 250bpm s.r.o.
+ Copyright (c) 2011 iMatix Corporation
+ Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -19,10 +20,13 @@
*/
#include <assert.h>
+#include <stdio.h>
#include "testutil.hpp"
int main (int argc, char *argv [])
{
+ fprintf (stderr, "test_reqrep_tcp running...\n");
+
void *ctx = zmq_init (1);
assert (ctx);
diff --git a/tests/test_shutdown_stress.cpp b/tests/test_shutdown_stress.cpp
index b3ee90f..811637c 100644
--- a/tests/test_shutdown_stress.cpp
+++ b/tests/test_shutdown_stress.cpp
@@ -1,6 +1,7 @@
/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
+ Copyright (c) 2010-2011 250bpm s.r.o.
+ Copyright (c) 2011 iMatix Corporation
+ Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -22,6 +23,7 @@
#include <assert.h>
#include <pthread.h>
#include <stddef.h>
+#include <stdio.h>
#define THREAD_COUNT 100
@@ -52,6 +54,8 @@ int main (int argc, char *argv [])
int rc;
pthread_t threads [THREAD_COUNT];
+ fprintf (stderr, "test_shutdown_stress running...\n");
+
for (j = 0; j != 10; j++) {
// Check the shutdown with many parallel I/O threads.
diff --git a/tests/test_sub_forward.cpp b/tests/test_sub_forward.cpp
index d69f923..36a7f4a 100644
--- a/tests/test_sub_forward.cpp
+++ b/tests/test_sub_forward.cpp
@@ -1,6 +1,7 @@
/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
+ Copyright (c) 2010-2011 250bpm s.r.o.
+ Copyright (c) 2011 iMatix Corporation
+ Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -19,12 +20,15 @@
*/
#include <assert.h>
+#include <stdio.h>
#include "../include/zmq.h"
#include "../include/zmq_utils.h"
int main (int argc, char *argv [])
{
+ fprintf (stderr, "test_sub_forward running...\n");
+
void *ctx = zmq_init (1);
assert (ctx);
diff --git a/tests/test_timeo.cpp b/tests/test_timeo.cpp
index a8a3fc0..29ba8a0 100644
--- a/tests/test_timeo.cpp
+++ b/tests/test_timeo.cpp
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2007-2011 iMatix Corporation
- Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
+ Copyright (c) 2010-2011 250bpm s.r.o.
+ Copyright (c) 2010-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
@@ -21,6 +21,7 @@
#include <assert.h>
#include <string.h>
#include <pthread.h>
+#include <stdio.h>
#include "../include/zmq.h"
#include "../include/zmq_utils.h"
@@ -45,6 +46,8 @@ extern "C"
int main (int argc, char *argv [])
{
+ fprintf (stderr, "test_timeo...\n");
+
void *ctx = zmq_init (1);
assert (ctx);
diff --git a/tests/testutil.hpp b/tests/testutil.hpp
index 57db3c4..e68dc32 100644
--- a/tests/testutil.hpp
+++ b/tests/testutil.hpp
@@ -1,4 +1,5 @@
/*
+ 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