Commit 7485b09c authored by Richard Newton's avatar Richard Newton

Fix tests on windows

parent 498dc379
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "testutil.hpp" #include "testutil.hpp"
#include "../include/zmq_utils.h" #include "../include/zmq_utils.h"
#include "../src/z85_codec.hpp" #include "../src/z85_codec.hpp"
#include "../src/platform.hpp" #include "platform.hpp"
// Test keys from the zmq_curve man page // Test keys from the zmq_curve man page
static char client_public [] = "Yne@$w-vo<fVvi]a<NY6T1ed:M$fCG*[IaLV{hID"; static char client_public [] = "Yne@$w-vo<fVvi]a<NY6T1ed:M$fCG*[IaLV{hID";
......
...@@ -18,10 +18,40 @@ ...@@ -18,10 +18,40 @@
*/ */
#include "../include/zmq.h" #include "../include/zmq.h"
#include "platform.hpp"
#if defined (ZMQ_HAVE_WINDOWS)
#include <WinSock2.h>
#include <stdexcept>
#else
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <unistd.h> #include <unistd.h>
#include <assert.h> #include <assert.h>
#endif
#if defined (ZMQ_HAVE_WINDOWS)
void initialise_network()
{
WSADATA info;
if (WSAStartup(MAKEWORD(2,0), &info) != 0)
{
throw std::runtime_error("Could not start WSA");
}
}
int close(int fd)
{
return closesocket(fd);
}
#else
void initialise_network()
{
}
#endif
// This test case stresses the system to shake out known configuration // This test case stresses the system to shake out known configuration
// problems. We're not using libzmq here but direct system calls. Note // problems. We're not using libzmq here but direct system calls. Note
...@@ -29,12 +59,15 @@ ...@@ -29,12 +59,15 @@
int main (void) int main (void)
{ {
initialise_network();
// Check that we can create 1,000 sockets // Check that we can create 1,000 sockets
int handle [1000]; int handle [1000];
int count; int count;
for (count = 0; count < 1000; count++) { for (count = 0; count < 1000; count++) {
handle [count] = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); handle [count] = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (handle [count] == -1) { if (handle [count] == -1) {
int err = ::WSAGetLastError();
printf ("W: Only able to create %d sockets on this box\n", count); printf ("W: Only able to create %d sockets on this box\n", count);
printf ("I: Tune your system to increase maximum allowed file handles\n"); printf ("I: Tune your system to increase maximum allowed file handles\n");
#if defined (ZMQ_HAVE_OSX) #if defined (ZMQ_HAVE_OSX)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment