From cfba1f07987434263843f4aaee11ec088ec6ced3 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 16 Feb 2012 10:05:11 +0900 Subject: Reconnect test extended to include IPC Signed-off-by: Martin Sustrik --- tests/test_reconnect.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_reconnect.cpp b/tests/test_reconnect.cpp index af1b3c1..9a62e1c 100644 --- a/tests/test_reconnect.cpp +++ b/tests/test_reconnect.cpp @@ -52,6 +52,33 @@ int main (int argc, char *argv []) rc = xs_recv (pull, buf, sizeof (buf), 0); assert (rc == 3); + // Clean up. + rc = xs_close (push); + assert (rc == 0); + rc = xs_close (pull); + assert (rc == 0); + + // Now, let's test the same scenario with IPC. + push = xs_socket (ctx, XS_PUSH); + assert (push); + pull = xs_socket (ctx, XS_PULL); + assert (push); + + // Connect before bind was done at the peer and send one message. + rc = xs_connect (push, "ipc:///tmp/tester"); + assert (rc == 0); + rc = xs_send (push, "ABC", 3, 0); + assert (rc == 3); + + // Wait a while for few attempts to reconnect to happen. + xs_sleep (1); + + // Bind the peer and get the message. + rc = xs_bind (pull, "ipc:///tmp/tester"); + assert (rc == 0); + rc = xs_recv (pull, buf, sizeof (buf), 0); + assert (rc == 3); + // Clean up. rc = xs_close (push); assert (rc == 0); -- cgit v1.2.3