diff --git a/contrib/win32/w32-posix-prototype/win32posix/Tests/socketiotests.cpp b/contrib/win32/w32-posix-prototype/win32posix/Tests/socketiotests.cpp
deleted file mode 100644
index 4777317..0000000
--- a/contrib/win32/w32-posix-prototype/win32posix/Tests/socketiotests.cpp
+++ /dev/null
@@ -1,220 +0,0 @@
-#include "CppUnitTest.h"
-extern "C" {
-#include "..\win32posix\w32posix.h"
-}
-
-using namespace Microsoft::VisualStudio::CppUnitTestFramework;
-
-#define PORT "34912"
-#define BACKLOG 2
-
-int
-unset_nonblock(int fd)
-{
- int val;
-
- val = fcntl(fd, F_GETFL, 0);
- if (val < 0) {
- return (-1);
- }
- if (!(val & O_NONBLOCK)) {
- return (0);
- }
- val &= ~O_NONBLOCK;
- if (fcntl(fd, F_SETFL, val) == -1) {
- return (-1);
- }
- return (0);
-}
-
-int
-set_nonblock(int fd)
-{
- int val;
-
- val = fcntl(fd, F_GETFL, 0);
- if (val < 0) {
- return (-1);
- }
- if (val & O_NONBLOCK) {
- return (0);
- }
- val |= O_NONBLOCK;
- if (fcntl(fd, F_SETFL, val) == -1) {
- return (-1);
- }
- return (0);
-
-}
-
-int listen_fd = -1;
-int accept_fd = -1;
-int connect_fd = -1;
-addrinfo *servinfo;
-
-int socket_prepare(char* ip)
-{
- addrinfo hints;
- memset(&hints, 0, sizeof(hints));
- hints.ai_socktype = SOCK_STREAM;
- if (getaddrinfo(ip, PORT, &hints, &servinfo) == -1)
- return -1;
-
- listen_fd = socket(servinfo->ai_family, servinfo->ai_socktype, servinfo->ai_protocol);
- connect_fd = socket(servinfo->ai_family, servinfo->ai_socktype, servinfo->ai_protocol);
- if ((listen_fd == -1) || (connect_fd == -1))
- return -1;
-
- if (-1 == bind(listen_fd, servinfo->ai_addr, servinfo->ai_addrlen))
- return -1;
-
- if (-1 == listen(listen_fd, BACKLOG))
- return -1;
-
- return 0;
-}
-
-#define READ_BUf_SIZE 1024 * 100
-#define WRITE_BUF_SIZE 1024 * 100
-
-namespace UnitTests
-{
- TEST_CLASS(SocketIOTests)
- {
-
- public:
-
- TEST_METHOD_INITIALIZE(TestMethodInitialize)
- {
- w32posix_initialize();
- listen_fd = -1;
- accept_fd = -1;
- connect_fd = -1;
- servinfo = NULL;
- }
-
- TEST_METHOD_CLEANUP(TestMethodCleanup)
- {
- if (servinfo) freeaddrinfo(servinfo);
- if (listen_fd != -1) close(listen_fd);
- if (connect_fd != -1) close(connect_fd);
- if (accept_fd != -1) close(accept_fd);
- w32posix_done();
- }
-
- TEST_METHOD(socketio)
- {
- int ret;
- ret = socket_prepare("127.0.0.1");
- Assert::AreEqual(ret, 0, L"failed to prepare sockets", LINE_INFO());
-
- ret = connect(connect_fd, servinfo->ai_addr, servinfo->ai_addrlen);
- Assert::AreEqual(ret, 0, L"", LINE_INFO());
-
- accept_fd = accept(listen_fd, NULL, NULL);
- Assert::AreNotEqual(accept_fd, -1, L"", LINE_INFO());
-
- //close(listen_fd);
- //listen_fd = -1;
-
- int c = connect_fd;
- int s = accept_fd;
-
- set_nonblock(c);
- set_nonblock(s);
-
- char *to_write = (char*)malloc(WRITE_BUF_SIZE);
-
- char *read_to = (char*)malloc(READ_BUf_SIZE);
-
- //write from c, read from s
- fd_set read_set;
- fd_set write_set;
- FD_ZERO(&read_set);
- FD_ZERO(&write_set);
- FD_SET(s, &read_set);
- FD_SET(c, &write_set);
- int max_fd = max(c, s) + 1;
- timeval time;
- time.tv_sec = 60 * 60;
- time.tv_usec = 0;
- long long bytes_written = 0;
- long long bytes_read = 0;
-
- while (-1 != select(max_fd, &read_set, &write_set, NULL, &time))
- {
- BOOL read_ready = FD_ISSET(s, &read_set);
- BOOL write_ready = FD_ISSET(c, &write_set);
- FD_ZERO(&read_set);
- FD_ZERO(&write_set);
- FD_SET(s, &read_set);
-
- if (write_ready)
- {
-
-#define WR_LIMIT WRITE_BUF_SIZE*5
-
- int bw = 0;// send(c, to_write, WRITE_BUF_SIZE, 0);
- while ((bw != -1) && (bytes_written < WR_LIMIT)) {
-
- bw = send(c, to_write, WRITE_BUF_SIZE, 0);
- if (bw > 0)
- bytes_written += bw;
- else {
- ret = errno;
- Assert::AreEqual(errno, EAGAIN, L"", LINE_INFO());
- }
-
- }
-
- if (bytes_written >= WR_LIMIT)
- {
- ret = shutdown(c, SD_SEND), 0, L"", LINE_INFO();
- Assert::AreEqual(ret, 0, L"", LINE_INFO());
- }
- else
- FD_SET(c, &write_set);
- }
-
-
-
- if (read_ready)
- {
- int br = read(s, read_to, READ_BUf_SIZE);
- while (br > 1) {
- bytes_read += br;
- br = read(s, read_to, READ_BUf_SIZE);
- }
-
- if (br == 0) //send from other side is done
- break;
- ret = errno;
- Assert::AreEqual(errno, EAGAIN, L"", LINE_INFO());
- }
-
- }
-
- Assert::AreEqual((bytes_written == bytes_read)? 1:0, TRUE, L"", LINE_INFO());
- }
-
- TEST_METHOD(TestMethod)
- {
- fd_set* set = (fd_set*)malloc(sizeof(fd_set));
-
- FD_ZERO(set);
- FD_SET(0, set);
- FD_SET(1, set);
-
- Assert::AreEqual(1, FD_ISSET(0, set), L"", LINE_INFO());
- Assert::AreEqual(1, FD_ISSET(1, set), L"", LINE_INFO());
- Assert::AreEqual(0, FD_ISSET(2, set), L"", LINE_INFO());
-
- FD_CLR(0, set);
- FD_CLR(1, set);
-
- Assert::AreEqual(0, FD_ISSET(0, set), L"", LINE_INFO());
- Assert::AreEqual(0, FD_ISSET(1, set), L"", LINE_INFO());
- Assert::AreEqual(0, FD_ISSET(2, set), L"", LINE_INFO());
- }
- };
-}
\ No newline at end of file
diff --git a/contrib/win32/w32-posix-prototype/win32posix/Tests/Tests.vcxproj b/contrib/win32/w32-posix-prototype/win32posix/UnitTests/UnitTests.vcxproj
similarity index 61%
rename from contrib/win32/w32-posix-prototype/win32posix/Tests/Tests.vcxproj
rename to contrib/win32/w32-posix-prototype/win32posix/UnitTests/UnitTests.vcxproj
index 027eaa1..966a22d 100644
--- a/contrib/win32/w32-posix-prototype/win32posix/Tests/Tests.vcxproj
+++ b/contrib/win32/w32-posix-prototype/win32posix/UnitTests/UnitTests.vcxproj
@@ -5,159 +5,154 @@
Debug
Win32
-
- Debug
- x64
-
Release
Win32
+
+ Debug
+ x64
+
Release
x64
- {76AFACE0-9135-4D82-9A65-3B82084211E6}
+ {31E868FF-DE6C-4CF7-9BF0-2C9B51DB58AD}
Win32Proj
- Tests
+ UnitTests
8.1
- DynamicLibrary
+ Application
true
v140
Unicode
- false
-
-
- DynamicLibrary
- true
- v140
- Unicode
- false
- DynamicLibrary
+ Application
false
v140
true
Unicode
- false
+
+
+ Application
+ true
+ v140
+ Unicode
- DynamicLibrary
+ Application
false
v140
true
Unicode
- false
-
-
+
-
+
-
+
+
+
+
true
- $(SolutionDir)bin\tests\$(Platform)\$(Configuration)\
+ $(SolutionDir)bin\unittests\$(Platform)\$(Configuration)\
+ $(Platform)\$(Configuration)\$(TargetName)\
true
- $(SolutionDir)bin\tests\$(Platform)\$(Configuration)\
- $(SolutionDir)bin\int\$(Platform)\$(Configuration)\
- true
+ false
- true
+ false
- NotUsing
+
+
Level3
Disabled
- $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;%(PreprocessorDefinitions)
- true
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ $(SolutionDir)\win32posix
- Windows
+ Console
true
- $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(SolutionDir)bin\lib\$(Platform)\$(Configuration)\
- Ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);win32posix.lib
+ $(SolutionDir)bin\lib\$(Platform)\$(Configuration)\
+ Ws2_32.lib;win32posix.lib;%(AdditionalDependencies)
- NotUsing
+
+
Level3
Disabled
- $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)
- WIN32;_DEBUG;%(PreprocessorDefinitions)
- true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- Windows
+ Console
true
- $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(SolutionDir)bin\lib\$(Platform)\$(Configuration)\
- Ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);win32posix.lib
Level3
- Use
+
+
MaxSpeed
true
true
- $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;%(PreprocessorDefinitions)
- true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- Windows
+ Console
true
true
true
- $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)
Level3
- Use
+
+
MaxSpeed
true
true
- $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)
- WIN32;NDEBUG;%(PreprocessorDefinitions)
- true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- Windows
+ Console
true
true
true
- $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)
-
+
+
+
+
+
+
diff --git a/contrib/win32/w32-posix-prototype/win32posix/Tests/Tests.vcxproj.filters b/contrib/win32/w32-posix-prototype/win32posix/UnitTests/UnitTests.vcxproj.filters
similarity index 72%
rename from contrib/win32/w32-posix-prototype/win32posix/Tests/Tests.vcxproj.filters
rename to contrib/win32/w32-posix-prototype/win32posix/UnitTests/UnitTests.vcxproj.filters
index 471a8f0..444896a 100644
--- a/contrib/win32/w32-posix-prototype/win32posix/Tests/Tests.vcxproj.filters
+++ b/contrib/win32/w32-posix-prototype/win32posix/UnitTests/UnitTests.vcxproj.filters
@@ -15,8 +15,19 @@
-
+
+ Source Files
+
+
+ Source Files
+
+
Source Files
+
+
+ Header Files
+
+
\ No newline at end of file
diff --git a/contrib/win32/w32-posix-prototype/win32posix/UnitTests/socket_tests.c b/contrib/win32/w32-posix-prototype/win32posix/UnitTests/socket_tests.c
new file mode 100644
index 0000000..892ae83
--- /dev/null
+++ b/contrib/win32/w32-posix-prototype/win32posix/UnitTests/socket_tests.c
@@ -0,0 +1,202 @@
+#include "w32posix.h"
+#include "test_helper.h"
+
+#define PORT "34912"
+#define BACKLOG 2
+
+int
+unset_nonblock(int fd)
+{
+ int val;
+
+ val = fcntl(fd, F_GETFL, 0);
+ if (val < 0) {
+ return (-1);
+ }
+ if (!(val & O_NONBLOCK)) {
+ return (0);
+ }
+ val &= ~O_NONBLOCK;
+ if (fcntl(fd, F_SETFL, val) == -1) {
+ return (-1);
+ }
+ return (0);
+}
+
+int
+set_nonblock(int fd)
+{
+ int val;
+
+ val = fcntl(fd, F_GETFL, 0);
+ if (val < 0) {
+ return (-1);
+ }
+ if (val & O_NONBLOCK) {
+ return (0);
+ }
+ val |= O_NONBLOCK;
+ if (fcntl(fd, F_SETFL, val) == -1) {
+ return (-1);
+ }
+ return (0);
+
+}
+
+int listen_fd = -1;
+int accept_fd = -1;
+int connect_fd = -1;
+struct addrinfo *servinfo;
+
+
+void socket_tests()
+{
+ TEST_START("test 1");
+ ASSERT_INT_EQ(1, 1);
+ w32posix_initialize();
+ TEST_DONE();
+
+ TEST_START("test 1");
+ ASSERT_INT_EQ(1, 0);
+ TEST_DONE();
+
+ TEST_START("test 1");
+ ASSERT_INT_EQ(1, 1);
+ TEST_DONE();
+
+ TEST_START("test 1");
+ ASSERT_INT_EQ(1, 1);
+ TEST_DONE();
+ return;
+}
+
+int socket_prepare(char* ip)
+{
+ struct addrinfo hints;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_socktype = SOCK_STREAM;
+ if (getaddrinfo(ip, PORT, &hints, &servinfo) == -1)
+ return -1;
+
+ listen_fd = socket(servinfo->ai_family, servinfo->ai_socktype, servinfo->ai_protocol);
+ connect_fd = socket(servinfo->ai_family, servinfo->ai_socktype, servinfo->ai_protocol);
+ if ((listen_fd == -1) || (connect_fd == -1))
+ return -1;
+
+ if (-1 == bind(listen_fd, servinfo->ai_addr, servinfo->ai_addrlen))
+ return -1;
+
+ if (-1 == listen(listen_fd, BACKLOG))
+ return -1;
+
+ return 0;
+}
+#define READ_BUf_SIZE 1024 * 100
+#define WRITE_BUF_SIZE 1024 * 100
+void sample()
+{
+ w32posix_initialize();
+ listen_fd = -1;
+ accept_fd = -1;
+ connect_fd = -1;
+ servinfo = NULL;
+
+ int ret;
+
+ ret = socket_prepare("127.0.0.1");
+ //Assert::AreEqual(ret, 0);
+
+ ret = connect(connect_fd, servinfo->ai_addr, servinfo->ai_addrlen);
+
+ accept_fd = accept(listen_fd, NULL, NULL);
+ //Assert::AreNotEqual(accept_fd, -1, L"", LINE_INFO());
+
+ //close(listen_fd);
+ //listen_fd = -1;
+
+ int c = connect_fd;
+ int s = accept_fd;
+
+ set_nonblock(c);
+ set_nonblock(s);
+
+ char *to_write = (char*)malloc(WRITE_BUF_SIZE);
+
+ char *read_to = (char*)malloc(READ_BUf_SIZE);
+
+ //write from c, read from s
+ fd_set read_set;
+ fd_set write_set;
+ FD_ZERO(&read_set);
+ FD_ZERO(&write_set);
+ FD_SET(s, &read_set);
+ FD_SET(c, &write_set);
+ int max_fd = max(c, s) + 1;
+ struct timeval time;
+ time.tv_sec = 60 * 60;
+ time.tv_usec = 0;
+ long long bytes_written = 0;
+ long long bytes_read = 0;
+
+ while (-1 != select(max_fd, &read_set, &write_set, NULL, &time))
+ {
+ BOOL read_ready = FD_ISSET(s, &read_set);
+ BOOL write_ready = FD_ISSET(c, &write_set);
+ FD_ZERO(&read_set);
+ FD_ZERO(&write_set);
+ FD_SET(s, &read_set);
+
+ if (write_ready)
+ {
+
+#define WR_LIMIT WRITE_BUF_SIZE*5
+
+ int bw = 0;// send(c, to_write, WRITE_BUF_SIZE, 0);
+ while ((bw != -1) && (bytes_written < WR_LIMIT)) {
+
+ bw = send(c, to_write, WRITE_BUF_SIZE, 0);
+ if (bw > 0)
+ bytes_written += bw;
+ else {
+ ret = errno;
+ //Assert::AreEqual(errno, EAGAIN, L"", LINE_INFO());
+ }
+
+ }
+
+ if (bytes_written >= WR_LIMIT)
+ {
+ ret = shutdown(c, SD_SEND);
+ //Assert::AreEqual(ret, 0, L"", LINE_INFO());
+ }
+ else
+ FD_SET(c, &write_set);
+ }
+
+
+
+ if (read_ready)
+ {
+ int br = read(s, read_to, READ_BUf_SIZE);
+ while (br > 1) {
+ bytes_read += br;
+ br = read(s, read_to, READ_BUf_SIZE);
+ }
+
+ if (br == 0) //send from other side is done
+ break;
+ ret = errno;
+ //Assert::AreEqual(errno, EAGAIN, L"", LINE_INFO());
+ }
+
+ }
+
+ //Assert::AreEqual((bytes_written == bytes_read) ? 1 : 0, TRUE, L"", LINE_INFO());
+
+ if (servinfo) freeaddrinfo(servinfo);
+ if (listen_fd != -1) close(listen_fd);
+ if (connect_fd != -1) close(connect_fd);
+ if (accept_fd != -1) close(accept_fd);
+ w32posix_done();
+}
+
diff --git a/contrib/win32/w32-posix-prototype/win32posix/UnitTests/test_helper.c b/contrib/win32/w32-posix-prototype/win32posix/UnitTests/test_helper.c
new file mode 100644
index 0000000..ebe3149
--- /dev/null
+++ b/contrib/win32/w32-posix-prototype/win32posix/UnitTests/test_helper.c
@@ -0,0 +1,535 @@
+/* $OpenBSD: test_helper.c,v 1.6 2015/03/03 20:42:49 djm Exp $ */
+/*
+ * Copyright (c) 2011 Damien Miller
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Utility functions/framework for regress tests */
+
+//#include "includes.h"
+
+#include
+//#include
+//#include
+
+#include
+#include
+#ifdef HAVE_STDINT_H
+# include
+#endif
+#include
+#include
+#include
+//#include
+#include
+
+//#include
+
+#if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H) && !defined(BROKEN_STRNVIS)
+# include
+#endif
+
+#include "test_helper.h"
+//#include "atomicio.h"
+
+#define TEST_CHECK_INT(r, pred) do { \
+ switch (pred) { \
+ case TEST_EQ: \
+ if (r == 0) \
+ return; \
+ break; \
+ case TEST_NE: \
+ if (r != 0) \
+ return; \
+ break; \
+ case TEST_LT: \
+ if (r < 0) \
+ return; \
+ break; \
+ case TEST_LE: \
+ if (r <= 0) \
+ return; \
+ break; \
+ case TEST_GT: \
+ if (r > 0) \
+ return; \
+ break; \
+ case TEST_GE: \
+ if (r >= 0) \
+ return; \
+ break; \
+ default: \
+ abort(); \
+ } \
+ } while (0)
+
+#define TEST_CHECK(x1, x2, pred) do { \
+ switch (pred) { \
+ case TEST_EQ: \
+ if (x1 == x2) \
+ return; \
+ break; \
+ case TEST_NE: \
+ if (x1 != x2) \
+ return; \
+ break; \
+ case TEST_LT: \
+ if (x1 < x2) \
+ return; \
+ break; \
+ case TEST_LE: \
+ if (x1 <= x2) \
+ return; \
+ break; \
+ case TEST_GT: \
+ if (x1 > x2) \
+ return; \
+ break; \
+ case TEST_GE: \
+ if (x1 >= x2) \
+ return; \
+ break; \
+ default: \
+ abort(); \
+ } \
+ } while (0)
+
+char *__progname;
+
+static int verbose_mode = 0;
+static int quiet_mode = 0;
+static char *active_test_name = NULL;
+static u_int test_number = 0;
+static test_onerror_func_t *test_onerror = NULL;
+static void *onerror_ctx = NULL;
+static const char *data_dir = NULL;
+static char subtest_info[512];
+
+#ifndef WIN32_FIXME
+void fatal(const char *fmt,...) {/*stub*/}
+void logit(const char *fmt,...) {/*stub*/}
+void debug3(const char *fmt,...) {/*stub*/}
+#endif
+
+int
+main(int argc, char **argv)
+{
+ int ch;
+ __progname = NULL;
+ /* Handle systems without __progname */
+ if (__progname == NULL) {
+ __progname = strrchr(argv[0], '\\');
+ if (__progname == NULL || __progname[1] == '\0')
+ __progname = argv[0];
+ else
+ __progname++;
+ if ((__progname = strdup(__progname)) == NULL) {
+ fprintf(stderr, "strdup failed\n");
+ exit(1);
+ }
+ }
+
+ //while ((ch = getopt(argc, argv, "vqd:")) != -1) {
+ // switch (ch) {
+ // case 'd':
+ // //data_dir = optarg;
+ // break;
+ // case 'q':
+ // verbose_mode = 0;
+ // quiet_mode = 1;
+ // break;
+ // case 'v':
+ // verbose_mode = 1;
+ // quiet_mode = 0;
+ // break;
+ // default:
+ // fprintf(stderr, "Unrecognised command line option\n");
+ // fprintf(stderr, "Usage: %s [-v]\n", __progname);
+ // exit(1);
+ // }
+ //}
+ verbose_mode = 1;
+ quiet_mode = 0;
+ setvbuf(stdout, NULL, _IONBF, 0);
+ if (!quiet_mode)
+ printf("%s: ", __progname);
+ if (verbose_mode)
+ printf("\n");
+
+ tests();
+
+ if (!quiet_mode)
+ printf(" %u tests ok\n", test_number);
+ return 0;
+}
+#ifndef WIN32_FIXME
+const char *
+test_data_file(const char *name)
+{
+ static char ret[PATH_MAX];
+
+ if (data_dir != NULL)
+ snprintf(ret, sizeof(ret), "%s/%s", data_dir, name);
+ else
+ strlcpy(ret, name, sizeof(ret));
+ if (access(ret, F_OK) != 0) {
+ fprintf(stderr, "Cannot access data file %s: %s\n",
+ ret, strerror(errno));
+ exit(1);
+ }
+ return ret;
+}
+#endif
+
+void
+test_info(char *s, size_t len)
+{
+ snprintf(s, len, "In test %u: \"%s\"%s%s\n", test_number,
+ active_test_name == NULL ? "" : active_test_name,
+ *subtest_info != '\0' ? " - " : "", subtest_info);
+}
+
+#ifdef SIGINFO
+static void
+siginfo(int unused __attribute__((__unused__)))
+{
+ char buf[256];
+
+ test_info(buf, sizeof(buf));
+ atomicio(vwrite, STDERR_FILENO, buf, strlen(buf));
+}
+#endif
+
+void
+test_start(const char *n)
+{
+ assert(active_test_name == NULL);
+ assert((active_test_name = strdup(n)) != NULL);
+ *subtest_info = '\0';
+ if (verbose_mode)
+ printf("test %u - \"%s\": ", test_number, active_test_name);
+ test_number++;
+#ifdef SIGINFO
+ signal(SIGINFO, siginfo);
+#endif
+}
+
+void
+set_onerror_func(test_onerror_func_t *f, void *ctx)
+{
+ test_onerror = f;
+ onerror_ctx = ctx;
+}
+
+void
+test_done(void)
+{
+ *subtest_info = '\0';
+ assert(active_test_name != NULL);
+ free(active_test_name);
+ active_test_name = NULL;
+ if (verbose_mode)
+ printf("OK\n");
+ else if (!quiet_mode) {
+ printf(".");
+ fflush(stdout);
+ }
+}
+
+void
+test_subtest_info(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsnprintf(subtest_info, sizeof(subtest_info), fmt, ap);
+ va_end(ap);
+}
+
+//void
+//ssl_err_check(const char *file, int line)
+//{
+// long openssl_error = ERR_get_error();
+//
+// if (openssl_error == 0)
+// return;
+//
+// fprintf(stderr, "\n%s:%d: uncaught OpenSSL error: %s",
+// file, line, ERR_error_string(openssl_error, NULL));
+// abort();
+//}
+
+static const char *
+pred_name(enum test_predicate p)
+{
+ switch (p) {
+ case TEST_EQ:
+ return "EQ";
+ case TEST_NE:
+ return "NE";
+ case TEST_LT:
+ return "LT";
+ case TEST_LE:
+ return "LE";
+ case TEST_GT:
+ return "GT";
+ case TEST_GE:
+ return "GE";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static void
+test_die(void)
+{
+ if (test_onerror != NULL)
+ test_onerror(onerror_ctx);
+ abort();
+}
+
+static void
+test_header(const char *file, int line, const char *a1, const char *a2,
+ const char *name, enum test_predicate pred)
+{
+ fprintf(stderr, "\n%s:%d test #%u \"%s\"%s%s\n",
+ file, line, test_number, active_test_name,
+ *subtest_info != '\0' ? " - " : "", subtest_info);
+ fprintf(stderr, "ASSERT_%s_%s(%s%s%s) failed:\n",
+ name, pred_name(pred), a1,
+ a2 != NULL ? ", " : "", a2 != NULL ? a2 : "");
+}
+
+//void
+//assert_bignum(const char *file, int line, const char *a1, const char *a2,
+// const BIGNUM *aa1, const BIGNUM *aa2, enum test_predicate pred)
+//{
+// int r = BN_cmp(aa1, aa2);
+//
+// TEST_CHECK_INT(r, pred);
+// test_header(file, line, a1, a2, "BIGNUM", pred);
+// fprintf(stderr, "%12s = 0x%s\n", a1, BN_bn2hex(aa1));
+// fprintf(stderr, "%12s = 0x%s\n", a2, BN_bn2hex(aa2));
+// test_die();
+//}
+
+void
+assert_string(const char *file, int line, const char *a1, const char *a2,
+ const char *aa1, const char *aa2, enum test_predicate pred)
+{
+ int r;
+
+ /* Verify pointers are not NULL */
+ assert_ptr(file, line, a1, "NULL", aa1, NULL, TEST_NE);
+ assert_ptr(file, line, a2, "NULL", aa2, NULL, TEST_NE);
+
+ r = strcmp(aa1, aa2);
+ TEST_CHECK_INT(r, pred);
+ test_header(file, line, a1, a2, "STRING", pred);
+ fprintf(stderr, "%12s = %s (len %zu)\n", a1, aa1, strlen(aa1));
+ fprintf(stderr, "%12s = %s (len %zu)\n", a2, aa2, strlen(aa2));
+ test_die();
+}
+
+static char *
+tohex(const void *_s, size_t l)
+{
+ u_int8_t *s = (u_int8_t *)_s;
+ size_t i, j;
+ const char *hex = "0123456789abcdef";
+ char *r = malloc((l * 2) + 1);
+
+ assert(r != NULL);
+ for (i = j = 0; i < l; i++) {
+ r[j++] = hex[(s[i] >> 4) & 0xf];
+ r[j++] = hex[s[i] & 0xf];
+ }
+ r[j] = '\0';
+ return r;
+}
+
+void
+assert_mem(const char *file, int line, const char *a1, const char *a2,
+ const void *aa1, const void *aa2, size_t l, enum test_predicate pred)
+{
+ int r;
+
+ if (l == 0)
+ return;
+ /* If length is >0, then verify pointers are not NULL */
+ assert_ptr(file, line, a1, "NULL", aa1, NULL, TEST_NE);
+ assert_ptr(file, line, a2, "NULL", aa2, NULL, TEST_NE);
+
+ r = memcmp(aa1, aa2, l);
+ TEST_CHECK_INT(r, pred);
+ test_header(file, line, a1, a2, "STRING", pred);
+ fprintf(stderr, "%12s = %s (len %zu)\n", a1, tohex(aa1, MIN(l, 256)), l);
+ fprintf(stderr, "%12s = %s (len %zu)\n", a2, tohex(aa2, MIN(l, 256)), l);
+ test_die();
+}
+
+static int
+memvalcmp(const u_int8_t *s, u_char v, size_t l, size_t *where)
+{
+ size_t i;
+
+ for (i = 0; i < l; i++) {
+ if (s[i] != v) {
+ *where = i;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+void
+assert_mem_filled(const char *file, int line, const char *a1,
+ const void *aa1, u_char v, size_t l, enum test_predicate pred)
+{
+ size_t where = -1;
+ int r;
+ char tmp[64];
+
+ if (l == 0)
+ return;
+ /* If length is >0, then verify the pointer is not NULL */
+ assert_ptr(file, line, a1, "NULL", aa1, NULL, TEST_NE);
+
+ r = memvalcmp(aa1, v, l, &where);
+ TEST_CHECK_INT(r, pred);
+ test_header(file, line, a1, NULL, "MEM_ZERO", pred);
+ fprintf(stderr, "%20s = %s%s (len %zu)\n", a1,
+ tohex(aa1, MIN(l, 20)), l > 20 ? "..." : "", l);
+ snprintf(tmp, sizeof(tmp), "(%s)[%zu]", a1, where);
+ fprintf(stderr, "%20s = 0x%02x (expected 0x%02x)\n", tmp,
+ ((u_char *)aa1)[where], v);
+ test_die();
+}
+
+void
+assert_int(const char *file, int line, const char *a1, const char *a2,
+ int aa1, int aa2, enum test_predicate pred)
+{
+ TEST_CHECK(aa1, aa2, pred);
+ test_header(file, line, a1, a2, "INT", pred);
+ fprintf(stderr, "%12s = %d\n", a1, aa1);
+ fprintf(stderr, "%12s = %d\n", a2, aa2);
+ test_die();
+}
+
+void
+assert_size_t(const char *file, int line, const char *a1, const char *a2,
+ size_t aa1, size_t aa2, enum test_predicate pred)
+{
+ TEST_CHECK(aa1, aa2, pred);
+ test_header(file, line, a1, a2, "SIZE_T", pred);
+ fprintf(stderr, "%12s = %zu\n", a1, aa1);
+ fprintf(stderr, "%12s = %zu\n", a2, aa2);
+ test_die();
+}
+
+void
+assert_u_int(const char *file, int line, const char *a1, const char *a2,
+ u_int aa1, u_int aa2, enum test_predicate pred)
+{
+ TEST_CHECK(aa1, aa2, pred);
+ test_header(file, line, a1, a2, "U_INT", pred);
+ fprintf(stderr, "%12s = %u / 0x%x\n", a1, aa1, aa1);
+ fprintf(stderr, "%12s = %u / 0x%x\n", a2, aa2, aa2);
+ test_die();
+}
+
+void
+assert_long_long(const char *file, int line, const char *a1, const char *a2,
+ long long aa1, long long aa2, enum test_predicate pred)
+{
+ TEST_CHECK(aa1, aa2, pred);
+ test_header(file, line, a1, a2, "LONG LONG", pred);
+ fprintf(stderr, "%12s = %lld / 0x%llx\n", a1, aa1, aa1);
+ fprintf(stderr, "%12s = %lld / 0x%llx\n", a2, aa2, aa2);
+ test_die();
+}
+
+void
+assert_char(const char *file, int line, const char *a1, const char *a2,
+ char aa1, char aa2, enum test_predicate pred)
+{
+ char buf[8];
+
+ TEST_CHECK(aa1, aa2, pred);
+ test_header(file, line, a1, a2, "CHAR", pred);
+ //fprintf(stderr, "%12s = '%s' / 0x02%x\n", a1,
+ // vis(buf, aa1, VIS_SAFE|VIS_NL|VIS_TAB|VIS_OCTAL, 0), aa1);
+ //fprintf(stderr, "%12s = '%s' / 0x02%x\n", a1,
+ // vis(buf, aa2, VIS_SAFE|VIS_NL|VIS_TAB|VIS_OCTAL, 0), aa2);
+ test_die();
+}
+
+void
+assert_u8(const char *file, int line, const char *a1, const char *a2,
+ u_int8_t aa1, u_int8_t aa2, enum test_predicate pred)
+{
+ TEST_CHECK(aa1, aa2, pred);
+ test_header(file, line, a1, a2, "U8", pred);
+ fprintf(stderr, "%12s = 0x%02x %u\n", a1, aa1, aa1);
+ fprintf(stderr, "%12s = 0x%02x %u\n", a2, aa2, aa2);
+ test_die();
+}
+
+void
+assert_u16(const char *file, int line, const char *a1, const char *a2,
+ u_int16_t aa1, u_int16_t aa2, enum test_predicate pred)
+{
+ TEST_CHECK(aa1, aa2, pred);
+ test_header(file, line, a1, a2, "U16", pred);
+ fprintf(stderr, "%12s = 0x%04x %u\n", a1, aa1, aa1);
+ fprintf(stderr, "%12s = 0x%04x %u\n", a2, aa2, aa2);
+ test_die();
+}
+
+void
+assert_u32(const char *file, int line, const char *a1, const char *a2,
+ u_int32_t aa1, u_int32_t aa2, enum test_predicate pred)
+{
+ TEST_CHECK(aa1, aa2, pred);
+ test_header(file, line, a1, a2, "U32", pred);
+ fprintf(stderr, "%12s = 0x%08x %u\n", a1, aa1, aa1);
+ fprintf(stderr, "%12s = 0x%08x %u\n", a2, aa2, aa2);
+ test_die();
+}
+
+void
+assert_u64(const char *file, int line, const char *a1, const char *a2,
+ u_int64_t aa1, u_int64_t aa2, enum test_predicate pred)
+{
+ TEST_CHECK(aa1, aa2, pred);
+ test_header(file, line, a1, a2, "U64", pred);
+ fprintf(stderr, "%12s = 0x%016llx %llu\n", a1,
+ (unsigned long long)aa1, (unsigned long long)aa1);
+ fprintf(stderr, "%12s = 0x%016llx %llu\n", a2,
+ (unsigned long long)aa2, (unsigned long long)aa2);
+ test_die();
+}
+
+void
+assert_ptr(const char *file, int line, const char *a1, const char *a2,
+ const void *aa1, const void *aa2, enum test_predicate pred)
+{
+ TEST_CHECK(aa1, aa2, pred);
+ test_header(file, line, a1, a2, "PTR", pred);
+ fprintf(stderr, "%12s = %p\n", a1, aa1);
+ fprintf(stderr, "%12s = %p\n", a2, aa2);
+ test_die();
+}
+
diff --git a/contrib/win32/w32-posix-prototype/win32posix/UnitTests/test_helper.h b/contrib/win32/w32-posix-prototype/win32posix/UnitTests/test_helper.h
new file mode 100644
index 0000000..2fc4088
--- /dev/null
+++ b/contrib/win32/w32-posix-prototype/win32posix/UnitTests/test_helper.h
@@ -0,0 +1,310 @@
+/* $OpenBSD: test_helper.h,v 1.6 2015/01/18 19:52:44 djm Exp $ */
+/*
+ * Copyright (c) 2011 Damien Miller
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Utility functions/framework for regress tests */
+
+#ifndef _TEST_HELPER_H
+#define _TEST_HELPER_H
+#define WIN32_FIXME
+#define __attribute__
+#define u_int8_t unsigned char
+#define u_int16_t unsigned short
+#define u_int32_t unsigned int
+#define u_int64_t unsigned __int64
+#define MIN min
+//#include "includes.h"
+
+#include
+#include
+#ifdef HAVE_STDINT_H
+# include
+#endif
+
+//#include
+//#include
+
+enum test_predicate {
+ TEST_EQ, TEST_NE, TEST_LT, TEST_LE, TEST_GT, TEST_GE
+};
+typedef void (test_onerror_func_t)(void *);
+
+/* Supplied by test suite */
+void tests(void);
+
+const char *test_data_file(const char *name);
+void test_start(const char *n);
+void test_info(char *s, size_t len);
+void set_onerror_func(test_onerror_func_t *f, void *ctx);
+void test_done(void);
+void test_subtest_info(const char *fmt, ...);
+// __attribute__((format(printf, 1, 2)));
+void ssl_err_check(const char *file, int line);
+//void assert_bignum(const char *file, int line,
+// const char *a1, const char *a2,
+// const BIGNUM *aa1, const BIGNUM *aa2, enum test_predicate pred);
+void assert_string(const char *file, int line,
+ const char *a1, const char *a2,
+ const char *aa1, const char *aa2, enum test_predicate pred);
+void assert_mem(const char *file, int line,
+ const char *a1, const char *a2,
+ const void *aa1, const void *aa2, size_t l, enum test_predicate pred);
+void assert_mem_filled(const char *file, int line,
+ const char *a1,
+ const void *aa1, u_char v, size_t l, enum test_predicate pred);
+void assert_int(const char *file, int line,
+ const char *a1, const char *a2,
+ int aa1, int aa2, enum test_predicate pred);
+void assert_size_t(const char *file, int line,
+ const char *a1, const char *a2,
+ size_t aa1, size_t aa2, enum test_predicate pred);
+void assert_u_int(const char *file, int line,
+ const char *a1, const char *a2,
+ u_int aa1, u_int aa2, enum test_predicate pred);
+void assert_long_long(const char *file, int line,
+ const char *a1, const char *a2,
+ long long aa1, long long aa2, enum test_predicate pred);
+void assert_char(const char *file, int line,
+ const char *a1, const char *a2,
+ char aa1, char aa2, enum test_predicate pred);
+void assert_ptr(const char *file, int line,
+ const char *a1, const char *a2,
+ const void *aa1, const void *aa2, enum test_predicate pred);
+void assert_u8(const char *file, int line,
+ const char *a1, const char *a2,
+ u_int8_t aa1, u_int8_t aa2, enum test_predicate pred);
+void assert_u16(const char *file, int line,
+ const char *a1, const char *a2,
+ u_int16_t aa1, u_int16_t aa2, enum test_predicate pred);
+void assert_u32(const char *file, int line,
+ const char *a1, const char *a2,
+ u_int32_t aa1, u_int32_t aa2, enum test_predicate pred);
+void assert_u64(const char *file, int line,
+ const char *a1, const char *a2,
+ u_int64_t aa1, u_int64_t aa2, enum test_predicate pred);
+
+#define TEST_START(n) test_start(n)
+#define TEST_DONE() test_done()
+#define TEST_ONERROR(f, c) set_onerror_func(f, c)
+#define SSL_ERR_CHECK() ssl_err_check(__FILE__, __LINE__)
+
+#define ASSERT_BIGNUM_EQ(a1, a2) \
+ assert_bignum(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
+#define ASSERT_STRING_EQ(a1, a2) \
+ assert_string(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
+#define ASSERT_MEM_EQ(a1, a2, l) \
+ assert_mem(__FILE__, __LINE__, #a1, #a2, a1, a2, l, TEST_EQ)
+#define ASSERT_MEM_FILLED_EQ(a1, c, l) \
+ assert_mem_filled(__FILE__, __LINE__, #a1, a1, c, l, TEST_EQ)
+#define ASSERT_MEM_ZERO_EQ(a1, l) \
+ assert_mem_filled(__FILE__, __LINE__, #a1, a1, '\0', l, TEST_EQ)
+#define ASSERT_INT_EQ(a1, a2) \
+ assert_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
+#define ASSERT_SIZE_T_EQ(a1, a2) \
+ assert_size_t(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
+#define ASSERT_U_INT_EQ(a1, a2) \
+ assert_u_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
+#define ASSERT_LONG_LONG_EQ(a1, a2) \
+ assert_long_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
+#define ASSERT_CHAR_EQ(a1, a2) \
+ assert_char(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
+#define ASSERT_PTR_EQ(a1, a2) \
+ assert_ptr(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
+#define ASSERT_U8_EQ(a1, a2) \
+ assert_u8(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
+#define ASSERT_U16_EQ(a1, a2) \
+ assert_u16(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
+#define ASSERT_U32_EQ(a1, a2) \
+ assert_u32(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
+#define ASSERT_U64_EQ(a1, a2) \
+ assert_u64(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_EQ)
+
+#define ASSERT_BIGNUM_NE(a1, a2) \
+ assert_bignum(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
+#define ASSERT_STRING_NE(a1, a2) \
+ assert_string(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
+#define ASSERT_MEM_NE(a1, a2, l) \
+ assert_mem(__FILE__, __LINE__, #a1, #a2, a1, a2, l, TEST_NE)
+#define ASSERT_MEM_ZERO_NE(a1, l) \
+ assert_mem_filled(__FILE__, __LINE__, #a1, a1, '\0', l, TEST_NE)
+#define ASSERT_INT_NE(a1, a2) \
+ assert_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
+#define ASSERT_SIZE_T_NE(a1, a2) \
+ assert_size_t(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
+#define ASSERT_U_INT_NE(a1, a2) \
+ assert_u_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
+#define ASSERT_LONG_LONG_NE(a1, a2) \
+ assert_long_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
+#define ASSERT_CHAR_NE(a1, a2) \
+ assert_char(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
+#define ASSERT_PTR_NE(a1, a2) \
+ assert_ptr(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
+#define ASSERT_U8_NE(a1, a2) \
+ assert_u8(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
+#define ASSERT_U16_NE(a1, a2) \
+ assert_u16(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
+#define ASSERT_U32_NE(a1, a2) \
+ assert_u32(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
+#define ASSERT_U64_NE(a1, a2) \
+ assert_u64(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_NE)
+
+#define ASSERT_BIGNUM_LT(a1, a2) \
+ assert_bignum(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
+#define ASSERT_STRING_LT(a1, a2) \
+ assert_string(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
+#define ASSERT_MEM_LT(a1, a2, l) \
+ assert_mem(__FILE__, __LINE__, #a1, #a2, a1, a2, l, TEST_LT)
+#define ASSERT_INT_LT(a1, a2) \
+ assert_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
+#define ASSERT_SIZE_T_LT(a1, a2) \
+ assert_size_t(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
+#define ASSERT_U_INT_LT(a1, a2) \
+ assert_u_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
+#define ASSERT_LONG_LONG_LT(a1, a2) \
+ assert_long_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
+#define ASSERT_CHAR_LT(a1, a2) \
+ assert_char(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
+#define ASSERT_PTR_LT(a1, a2) \
+ assert_ptr(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
+#define ASSERT_U8_LT(a1, a2) \
+ assert_u8(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
+#define ASSERT_U16_LT(a1, a2) \
+ assert_u16(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
+#define ASSERT_U32_LT(a1, a2) \
+ assert_u32(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
+#define ASSERT_U64_LT(a1, a2) \
+ assert_u64(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LT)
+
+#define ASSERT_BIGNUM_LE(a1, a2) \
+ assert_bignum(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
+#define ASSERT_STRING_LE(a1, a2) \
+ assert_string(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
+#define ASSERT_MEM_LE(a1, a2, l) \
+ assert_mem(__FILE__, __LINE__, #a1, #a2, a1, a2, l, TEST_LE)
+#define ASSERT_INT_LE(a1, a2) \
+ assert_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
+#define ASSERT_SIZE_T_LE(a1, a2) \
+ assert_size_t(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
+#define ASSERT_U_INT_LE(a1, a2) \
+ assert_u_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
+#define ASSERT_LONG_LONG_LE(a1, a2) \
+ assert_long_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
+#define ASSERT_CHAR_LE(a1, a2) \
+ assert_char(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
+#define ASSERT_PTR_LE(a1, a2) \
+ assert_ptr(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
+#define ASSERT_U8_LE(a1, a2) \
+ assert_u8(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
+#define ASSERT_U16_LE(a1, a2) \
+ assert_u16(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
+#define ASSERT_U32_LE(a1, a2) \
+ assert_u32(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
+#define ASSERT_U64_LE(a1, a2) \
+ assert_u64(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_LE)
+
+#define ASSERT_BIGNUM_GT(a1, a2) \
+ assert_bignum(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
+#define ASSERT_STRING_GT(a1, a2) \
+ assert_string(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
+#define ASSERT_MEM_GT(a1, a2, l) \
+ assert_mem(__FILE__, __LINE__, #a1, #a2, a1, a2, l, TEST_GT)
+#define ASSERT_INT_GT(a1, a2) \
+ assert_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
+#define ASSERT_SIZE_T_GT(a1, a2) \
+ assert_size_t(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
+#define ASSERT_U_INT_GT(a1, a2) \
+ assert_u_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
+#define ASSERT_LONG_LONG_GT(a1, a2) \
+ assert_long_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
+#define ASSERT_CHAR_GT(a1, a2) \
+ assert_char(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
+#define ASSERT_PTR_GT(a1, a2) \
+ assert_ptr(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
+#define ASSERT_U8_GT(a1, a2) \
+ assert_u8(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
+#define ASSERT_U16_GT(a1, a2) \
+ assert_u16(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
+#define ASSERT_U32_GT(a1, a2) \
+ assert_u32(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
+#define ASSERT_U64_GT(a1, a2) \
+ assert_u64(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GT)
+
+#define ASSERT_BIGNUM_GE(a1, a2) \
+ assert_bignum(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
+#define ASSERT_STRING_GE(a1, a2) \
+ assert_string(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
+#define ASSERT_MEM_GE(a1, a2, l) \
+ assert_mem(__FILE__, __LINE__, #a1, #a2, a1, a2, l, TEST_GE)
+#define ASSERT_INT_GE(a1, a2) \
+ assert_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
+#define ASSERT_SIZE_T_GE(a1, a2) \
+ assert_size_t(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
+#define ASSERT_U_INT_GE(a1, a2) \
+ assert_u_int(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
+#define ASSERT_LONG_LONG_GE(a1, a2) \
+ assert_long_long(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
+#define ASSERT_CHAR_GE(a1, a2) \
+ assert_char(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
+#define ASSERT_PTR_GE(a1, a2) \
+ assert_ptr(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
+#define ASSERT_U8_GE(a1, a2) \
+ assert_u8(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
+#define ASSERT_U16_GE(a1, a2) \
+ assert_u16(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
+#define ASSERT_U32_GE(a1, a2) \
+ assert_u32(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
+#define ASSERT_U64_GE(a1, a2) \
+ assert_u64(__FILE__, __LINE__, #a1, #a2, a1, a2, TEST_GE)
+
+/* Fuzzing support */
+
+struct fuzz;
+#define FUZZ_1_BIT_FLIP 0x00000001 /* Flip one bit at a time */
+#define FUZZ_2_BIT_FLIP 0x00000002 /* Flip two bits at a time */
+#define FUZZ_1_BYTE_FLIP 0x00000004 /* Flip one byte at a time */
+#define FUZZ_2_BYTE_FLIP 0x00000008 /* Flip two bytes at a time */
+#define FUZZ_TRUNCATE_START 0x00000010 /* Truncate from beginning */
+#define FUZZ_TRUNCATE_END 0x00000020 /* Truncate from end */
+#define FUZZ_BASE64 0x00000040 /* Try all base64 chars */
+#define FUZZ_MAX FUZZ_BASE64
+
+/* Start fuzzing a blob of data with selected strategies (bitmask) */
+struct fuzz *fuzz_begin(u_int strategies, const void *p, size_t l);
+
+/* Free a fuzz context */
+void fuzz_cleanup(struct fuzz *fuzz);
+
+/* Prepare the next fuzz case in the series */
+void fuzz_next(struct fuzz *fuzz);
+
+/*
+ * Check whether this fuzz case is identical to the original
+ * This is slow, but useful if the caller needs to ensure that all tests
+ * generated change the input (e.g. when fuzzing signatures).
+ */
+int fuzz_matches_original(struct fuzz *fuzz);
+
+/* Determine whether the current fuzz sequence is exhausted (nonzero = yes) */
+int fuzz_done(struct fuzz *fuzz);
+
+/* Return the length and a pointer to the current fuzzed case */
+size_t fuzz_len(struct fuzz *fuzz);
+u_char *fuzz_ptr(struct fuzz *fuzz);
+
+/* Dump the current fuzz case to stderr */
+void fuzz_dump(struct fuzz *fuzz);
+
+#endif /* _TEST_HELPER_H */
diff --git a/contrib/win32/w32-posix-prototype/win32posix/UnitTests/tests.c b/contrib/win32/w32-posix-prototype/win32posix/UnitTests/tests.c
new file mode 100644
index 0000000..72f0e3c
--- /dev/null
+++ b/contrib/win32/w32-posix-prototype/win32posix/UnitTests/tests.c
@@ -0,0 +1,11 @@
+#include "test_helper.h"
+
+void socket_tests();
+
+void tests(void)
+{
+ _set_abort_behavior(0, 1);
+
+ socket_tests();
+ return;
+}
\ No newline at end of file
diff --git a/contrib/win32/w32-posix-prototype/win32posix/win32posix.sln b/contrib/win32/w32-posix-prototype/win32posix/win32posix.sln
index c4ef704..cee4657 100644
--- a/contrib/win32/w32-posix-prototype/win32posix/win32posix.sln
+++ b/contrib/win32/w32-posix-prototype/win32posix/win32posix.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
-VisualStudioVersion = 14.0.24720.0
+VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "win32posix", "win32posix\win32posix.vcxproj", "{D8744F47-1741-4FB8-97D3-EBB9C3A13E67}"
EndProject
@@ -15,6 +15,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleServer", "SampleServe
{D8744F47-1741-4FB8-97D3-EBB9C3A13E67} = {D8744F47-1741-4FB8-97D3-EBB9C3A13E67}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTests", "UnitTests\UnitTests.vcxproj", "{31E868FF-DE6C-4CF7-9BF0-2C9B51DB58AD}"
+ ProjectSection(ProjectDependencies) = postProject
+ {D8744F47-1741-4FB8-97D3-EBB9C3A13E67} = {D8744F47-1741-4FB8-97D3-EBB9C3A13E67}
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -47,6 +52,14 @@ Global
{D52F8255-C3A9-4416-A0A6-8CE63A4D7E43}.Release|Win32.Build.0 = Release|Win32
{D52F8255-C3A9-4416-A0A6-8CE63A4D7E43}.Release|x64.ActiveCfg = Release|x64
{D52F8255-C3A9-4416-A0A6-8CE63A4D7E43}.Release|x64.Build.0 = Release|x64
+ {31E868FF-DE6C-4CF7-9BF0-2C9B51DB58AD}.Debug|Win32.ActiveCfg = Debug|Win32
+ {31E868FF-DE6C-4CF7-9BF0-2C9B51DB58AD}.Debug|Win32.Build.0 = Debug|Win32
+ {31E868FF-DE6C-4CF7-9BF0-2C9B51DB58AD}.Debug|x64.ActiveCfg = Debug|x64
+ {31E868FF-DE6C-4CF7-9BF0-2C9B51DB58AD}.Debug|x64.Build.0 = Debug|x64
+ {31E868FF-DE6C-4CF7-9BF0-2C9B51DB58AD}.Release|Win32.ActiveCfg = Release|Win32
+ {31E868FF-DE6C-4CF7-9BF0-2C9B51DB58AD}.Release|Win32.Build.0 = Release|Win32
+ {31E868FF-DE6C-4CF7-9BF0-2C9B51DB58AD}.Release|x64.ActiveCfg = Release|x64
+ {31E868FF-DE6C-4CF7-9BF0-2C9B51DB58AD}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE