summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-10-13 10:59:35 -0700
committerGarrett D'Amore <garrett@damore.org>2017-10-13 10:59:35 -0700
commit65c659b278668bad61b54e993cb348a083a0c9ca (patch)
tree15d2f67245059d89fe213160c82a1e1fef03b0c2
parentc8fc0c93158ba633d5f140fd0a97e8680fed13dd (diff)
downloadnanomsg-65c659b278668bad61b54e993cb348a083a0c9ca.tar.gz
fixes #871 Tests failed when building on WSL
-rw-r--r--CMakeLists.txt11
-rw-r--r--src/aio/usock_posix.inc6
-rw-r--r--tests/ipc.c3
-rw-r--r--tests/ipc_shutdown.c8
-rw-r--r--tests/ipc_stress.c12
-rw-r--r--tests/separation.c3
-rw-r--r--tests/tcp_shutdown.c6
7 files changed, 43 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a165387..5274442 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,8 +2,8 @@
# Copyright (c) 2012 Martin Sustrik All rights reserved.
# Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
# Copyright (c) 2015-2016 Jack R. Dunaway. All rights reserved.
-# Copyright 2016 Garrett D'Amore <garrett@damore.org>
# Copyright 2016 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
+# Copyright 2017 Garrett D'Amore <garrett@damore.org>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"),
@@ -107,8 +107,13 @@ set (NN_MAX_SOCKETS 512 CACHE STRING "max number of nanomsg sockets that can be
find_package (Threads REQUIRED)
+message(STATUS "OS System is ${CMAKE_SYSTEM_NAME}")
+message(STATUS "OS Version is ${CMAKE_SYSTEM_VERSION}")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions (-DNN_HAVE_LINUX)
+ if (CMAKE_SYSTEM_VERSION MATCHES "Microsoft")
+ add_definitions (-DNN_HAVE_WSL)
+ endif()
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions (-DNN_HAVE_OSX)
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
@@ -365,9 +370,9 @@ if (NN_TESTS)
add_libnanomsg_test (ipc 5)
add_libnanomsg_test (ipc_shutdown 30)
add_libnanomsg_test (ipc_stress 5)
- add_libnanomsg_test (tcp 5)
+ add_libnanomsg_test (tcp 20)
add_libnanomsg_test (tcp_shutdown 120)
- add_libnanomsg_test (ws 5)
+ add_libnanomsg_test (ws 20)
# Protocol tests.
add_libnanomsg_test (pair 5)
diff --git a/src/aio/usock_posix.inc b/src/aio/usock_posix.inc
index f020a22..0d2f805 100644
--- a/src/aio/usock_posix.inc
+++ b/src/aio/usock_posix.inc
@@ -1,7 +1,7 @@
/*
Copyright (c) 2013 Martin Sustrik All rights reserved.
Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
- Copyright 2016 Garrett D'Amore <garrett@damore.org>
+ Copyright 2017 Garrett D'Amore <garrett@damore.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
@@ -290,10 +290,14 @@ int nn_usock_bind (struct nn_usock *self, const struct sockaddr *addr,
/* The socket can be bound only before it's connected. */
nn_assert_state (self, NN_USOCK_STATE_STARTING);
+ /* Windows Subsystem for Linux - SO_REUSEADDR is different,
+ and the Windows semantics are very wrong for us. */
+#ifndef NN_HAVE_WSL
/* Allow re-using the address. */
opt = 1;
rc = setsockopt (self->s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof (opt));
errno_assert (rc == 0);
+#endif
rc = bind (self->s, addr, (socklen_t) addrlen);
if (nn_slow (rc != 0))
diff --git a/tests/ipc.c b/tests/ipc.c
index 8a8f7cb..ea41dc0 100644
--- a/tests/ipc.c
+++ b/tests/ipc.c
@@ -1,5 +1,6 @@
/*
Copyright (c) 2012 Martin Sustrik All rights reserved.
+ Copyright 2017 Garrett D'Amore <garrett@damore.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
@@ -33,6 +34,7 @@
int main ()
{
+#ifndef NN_HAVE_WSL
int sb;
int sc;
int i;
@@ -161,6 +163,7 @@ int main ()
test_connect (sc, SOCKET_ADDRESS);
nn_sleep (100);
test_close (sc);
+#endif /* NN_HAVE_WSL */
return 0;
}
diff --git a/tests/ipc_shutdown.c b/tests/ipc_shutdown.c
index a69bd35..0eeb89b 100644
--- a/tests/ipc_shutdown.c
+++ b/tests/ipc_shutdown.c
@@ -1,5 +1,6 @@
/*
Copyright (c) 2012 Martin Sustrik All rights reserved.
+ Copyright 2017 Garrett D'Amore <garrett@damore.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
@@ -29,6 +30,8 @@
#include "testutil.h"
#include "../src/utils/thread.c"
+#ifndef NN_HAVE_WSL
+
/* Stress test the IPC transport. */
#define THREAD_COUNT 100
@@ -70,8 +73,12 @@ static void routine2 (NN_UNUSED void *arg)
active --;
}
+#endif /* NN_HAVE_WSL */
+
int main ()
{
+
+#ifndef NN_HAVE_WSL
int sb;
int i;
int j;
@@ -115,6 +122,7 @@ int main ()
}
test_close (sb);
+#endif /* NN_HAVE_WSL */
return 0;
}
diff --git a/tests/ipc_stress.c b/tests/ipc_stress.c
index 91b45c5..a3bbf84 100644
--- a/tests/ipc_stress.c
+++ b/tests/ipc_stress.c
@@ -1,6 +1,6 @@
/*
Copyright (c) 2012 Martin Sustrik All rights reserved.
- Copyright 2015 Garrett D'Amore <garrett@damore.org>
+ Copyright 2017 Garrett D'Amore <garrett@damore.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
@@ -34,6 +34,8 @@
/* Stress test the IPC transport. */
+#ifndef NN_HAVE_WSL
+
#define THREAD_COUNT 10
#define TEST_LOOPS 10
#define SOCKET_ADDRESS "ipc://test-stress.ipc"
@@ -113,3 +115,11 @@ int main()
return 0;
}
+
+#else
+
+int main()
+{
+ return (0);
+}
+#endif
diff --git a/tests/separation.c b/tests/separation.c
index 7545d4e..c547a24 100644
--- a/tests/separation.c
+++ b/tests/separation.c
@@ -2,6 +2,7 @@
Copyright (c) 2013 Martin Sustrik All rights reserved.
Copyright (c) 2013 GoPivotal, Inc. All rights reserved.
Copyright 2016 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
+ Copyright 2017 Garrett D'Amore <garrett@damore.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
@@ -73,7 +74,7 @@ int main (int argc, const char *argv[])
test_close (pull);
test_close (pair);
-#if !defined NN_HAVE_WINDOWS
+#if !defined NN_HAVE_WINDOWS && !defined NN_HAVE_WSL
/* IPC */
pair = test_socket (AF_SP, NN_PAIR);
diff --git a/tests/tcp_shutdown.c b/tests/tcp_shutdown.c
index 79d2754..075c943 100644
--- a/tests/tcp_shutdown.c
+++ b/tests/tcp_shutdown.c
@@ -1,6 +1,7 @@
/*
Copyright (c) 2012 Martin Sustrik All rights reserved.
Copyright 2016 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
+ Copyright 2017 Garrett D'Amore <garrett@damore.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),
@@ -34,7 +35,12 @@
/* Stress test the TCP transport. */
+#ifdef NN_HAVE_WSL
+#define THREAD_COUNT 10
+#else
#define THREAD_COUNT 100
+#endif
+
#define TEST2_THREAD_COUNT 10
#define MESSAGES_PER_THREAD 10
#define TEST_LOOPS 10