From 456430c6762291bd404e3ad78380cb9e90dcb77b Mon Sep 17 00:00:00 2001 From: henri Date: Tue, 13 Aug 2013 12:36:28 +0000 Subject: [PATCH] Windows compatibility fix. Initialize winsock before starting nsock test suite. Initial patch from Gisle Vanem. --- nsock/tests/tests_main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nsock/tests/tests_main.c b/nsock/tests/tests_main.c index dfdf74145..27d024a03 100644 --- a/nsock/tests/tests_main.c +++ b/nsock/tests/tests_main.c @@ -69,9 +69,25 @@ static int test_case_run(const struct test_case *test) { return test_teardown(test, tdata); } +#ifdef WIN32 +static int win_init(void) { + WSADATA data; + + rc = WSAStartup(MAKEWORD(2, 2), &data); + if (rc) + fatal("Failed to start winsock: %s\n", socket_strerror(rc)); + + return 0; +} +#endif + int main(int ac, char **av) { int rc, i; +#ifdef WIN32 + win_init(); +#endif + for (i = 0; TestCases[i] != NULL; i++) { const struct test_case *current = TestCases[i]; const char *name = get_test_name(current);