summaryrefslogtreecommitdiff
path: root/tests/libzmq21.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libzmq21.cpp')
-rw-r--r--tests/libzmq21.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/tests/libzmq21.cpp b/tests/libzmq21.cpp
index ecf271b..ea02f7d 100644
--- a/tests/libzmq21.cpp
+++ b/tests/libzmq21.cpp
@@ -50,14 +50,14 @@ int XS_TEST_MAIN ()
// Create the basic infrastructure.
void *ctx = xs_init ();
- assert (ctx);
+ errno_assert (ctx);
void *pub = xs_socket (ctx, XS_PUB);
- assert (pub);
+ errno_assert (pub);
int protocol = 1;
int rc = xs_setsockopt (pub, XS_PROTOCOL, &protocol, sizeof (protocol));
- assert (rc == 0);
+ errno_assert (rc == 0);
rc = xs_bind (pub, "tcp://127.0.0.1:5560");
- assert (rc != -1);
+ errno_assert (rc != -1);
int oldsub = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
struct sockaddr_in address;
@@ -65,7 +65,7 @@ int XS_TEST_MAIN ()
address.sin_addr.s_addr = inet_addr ("127.0.0.1");
address.sin_port = htons (5560);
rc = connect (oldsub, (struct sockaddr*) &address, sizeof (address));
- assert (rc == 0);
+ errno_assert (rc == 0);
// Wait a while to allow connection to be accepted on the publisher side.
sleep (1);
@@ -73,46 +73,46 @@ int XS_TEST_MAIN ()
// Send a message and check whether it arrives although there was no
// subscription sent.
rc = xs_send (pub, "ABC", 3, 0);
- assert (rc == 3);
+ errno_assert (rc == 3);
char buf [5];
rc = recv (oldsub, buf, sizeof (buf), 0);
- assert (rc == 5);
+ errno_assert (rc == 5);
assert (!memcmp (buf, "\x04\0ABC", 5));
// Tear down the infrastructure.
rc = xs_close (pub);
- assert (rc == 0);
+ errno_assert (rc == 0);
#if defined XS_HAVE_WINDOWS
rc = closesocket (oldsub);
assert (rc != SOCKET_ERROR);
#else
rc = close (oldsub);
- assert (rc == 0);
+ errno_assert (rc == 0);
#endif
rc = xs_term (ctx);
- assert (rc == 0);
+ errno_assert (rc == 0);
// Second, test the 0MQ/2.1-style publisher with up-to-date subscriber.
// Create the basic infrastructure.
ctx = xs_init ();
- assert (ctx);
+ errno_assert (ctx);
void *sub = xs_socket (ctx, XS_SUB);
- assert (sub);
+ errno_assert (sub);
protocol = 1;
rc = xs_setsockopt (sub, XS_PROTOCOL, &protocol, sizeof (protocol));
- assert (rc == 0);
+ errno_assert (rc == 0);
rc = xs_setsockopt (sub, XS_SUBSCRIBE, "", 0);
- assert (rc == 0);
+ errno_assert (rc == 0);
rc = xs_bind (sub, "tcp://127.0.0.1:5560");
- assert (rc != -1);
+ errno_assert (rc != -1);
int oldpub = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
address.sin_family = AF_INET;
address.sin_addr.s_addr = inet_addr ("127.0.0.1");
address.sin_port = htons (5560);
rc = connect (oldpub, (struct sockaddr*) &address, sizeof (address));
- assert (rc == 0);
+ errno_assert (rc == 0);
// Wait a while to allow connection to be accepted on the subscriber side.
sleep (1);
@@ -125,13 +125,13 @@ int XS_TEST_MAIN ()
#elif XS_HAVE_OPENVMS
int nonblock = 1;
rc = ioctl (oldpub, FIONBIO, &nonblock);
- assert (rc != -1);
+ errno_assert (rc != -1);
#else
int flags = fcntl (oldpub, F_GETFL, 0);
if (flags == -1)
flags = 0;
rc = fcntl (oldpub, F_SETFL, flags | O_NONBLOCK);
- assert (rc != -1);
+ errno_assert (rc != -1);
#endif
// Check that subscription haven't arrived at the publisher side.
@@ -139,33 +139,33 @@ int XS_TEST_MAIN ()
#if defined XS_HAVE_WINDOWS
assert (rc == SOCKET_ERROR && WSAGetLastError () == WSAEWOULDBLOCK);
#else
- assert (rc == -1 && (errno == EAGAIN || errno == EWOULDBLOCK));
+ errno_assert (rc == -1 && (errno == EAGAIN || errno == EWOULDBLOCK));
#endif
// Pass one message through.
rc = send (oldpub, "\x04\0ABC", 5, 0);
- assert (rc == 5);
+ errno_assert (rc == 5);
rc = xs_recv (sub, buf, sizeof (buf), 0);
- assert (rc == 3);
+ errno_assert (rc == 3);
// Pass one message with usused flags set (0MQ/2.1 bug).
rc = send (oldpub, "\x04\xfe" "ABC", 5, 0);
- assert (rc == 5);
+ errno_assert (rc == 5);
rc = xs_recv (sub, buf, sizeof (buf), 0);
- assert (rc == 3);
+ errno_assert (rc == 3);
// Tear down the infrastructure.
rc = xs_close (sub);
- assert (rc == 0);
+ errno_assert (rc == 0);
#if defined XS_HAVE_WINDOWS
rc = closesocket (oldpub);
assert (rc != SOCKET_ERROR);
#else
rc = close (oldpub);
- assert (rc == 0);
+ errno_assert (rc == 0);
#endif
rc = xs_term (ctx);
- assert (rc == 0);
+ errno_assert (rc == 0);
#if defined XS_HAVE_WINDOWS
WSACleanup ();