From 046e37e907ee55fdcad000030a42c947659a6c60 Mon Sep 17 00:00:00 2001 From: Pieter Hintjens Date: Wed, 29 Jan 2014 20:16:58 +0100 Subject: [PATCH] Test for 127.0.0.1 at tests startup --- tests/test_system.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/test_system.cpp b/tests/test_system.cpp index e1d72732..c758d8d0 100644 --- a/tests/test_system.cpp +++ b/tests/test_system.cpp @@ -30,36 +30,43 @@ #if defined (ZMQ_HAVE_WINDOWS) -void initialise_network() +void initialise_network (void) { WSADATA info; if (WSAStartup(MAKEWORD(2,0), &info) != 0) - { throw std::runtime_error("Could not start WSA"); - } } -int close(int fd) +int close (int fd) { - return closesocket(fd); + return closesocket (fd); } #else -void initialise_network() +void initialise_network (void) { } #endif // This test case stresses the system to shake out known configuration -// problems. We're not using libzmq here but direct system calls. Note -// that code may need wrapping to be properly portable. +// problems. We're direct system calls when necessary. Some code may +// need wrapping to be properly portable. int main (void) { - initialise_network(); + initialise_network (); + // Check that we have local networking via ZeroMQ + void *ctx = zmq_ctx_new (); + assert (ctx); + void *dealer = zmq_socket (ctx, ZMQ_DEALER); + if (zmq_bind (dealer, "tcp://127.0.0.1:5670") == -1) { + printf ("E: Cannot find 127.0.0.1 -- your system does not have local\n"); + printf ("E: networking. Please fix this before running libzmq checks.\n"); + return -1; + } // Check that we can create 1,000 sockets int handle [1000]; int count;