From: Nick Mathewson Date: Sat, 8 May 2010 22:00:26 +0000 (-0400) Subject: Make test.sh support mingw/msys on win32 X-Git-Tag: release-2.0.5-beta~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ee6f6ce805570576755142d28022c27446e27cc;p=libevent Make test.sh support mingw/msys on win32 This required: - Adding another WIN32 section in test.sh - not running "touch /dev/null" - calling WSAStartup in all the test binaries - Fixing a dumb windows-only bug in test-time.c --- diff --git a/test/test-eof.c b/test/test-eof.c index a5933c51..001370a8 100644 --- a/test/test-eof.c +++ b/test/test-eof.c @@ -64,6 +64,16 @@ main(int argc, char **argv) const char *test = "test string"; int pair[2]; +#ifdef WIN32 + WORD wVersionRequested; + WSADATA wsaData; + int err; + + wVersionRequested = MAKEWORD(2, 2); + + err = WSAStartup(wVersionRequested, &wsaData); +#endif + if (evutil_socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == -1) return (1); diff --git a/test/test-init.c b/test/test-init.c index 68ad561a..3806c15d 100644 --- a/test/test-init.c +++ b/test/test-init.c @@ -26,6 +26,16 @@ int main(int argc, char **argv) { +#ifdef WIN32 + WORD wVersionRequested; + WSADATA wsaData; + int err; + + wVersionRequested = MAKEWORD(2, 2); + + err = WSAStartup(wVersionRequested, &wsaData); +#endif + /* Initalize the event library */ event_init(); diff --git a/test/test-time.c b/test/test-time.c index c1b449b2..24daf8c8 100644 --- a/test/test-time.c +++ b/test/test-time.c @@ -30,7 +30,7 @@ static int rand_int(int n) { #ifdef WIN32 - return (int)(rand() * n); + return (int)(rand() % n); #else return (int)(random() % n); #endif @@ -62,6 +62,15 @@ main(int argc, char **argv) { struct timeval tv; int i; +#ifdef WIN32 + WORD wVersionRequested; + WSADATA wsaData; + int err; + + wVersionRequested = MAKEWORD(2, 2); + + err = WSAStartup(wVersionRequested, &wsaData); +#endif /* Initalize the event library */ event_init(); diff --git a/test/test-weof.c b/test/test-weof.c index e5ff99d2..946d3a0b 100644 --- a/test/test-weof.c +++ b/test/test-weof.c @@ -63,6 +63,16 @@ main(int argc, char **argv) { struct event ev; +#ifdef WIN32 + WORD wVersionRequested; + WSADATA wsaData; + int err; + + wVersionRequested = MAKEWORD(2, 2); + + err = WSAStartup(wVersionRequested, &wsaData); +#endif + #ifndef WIN32 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) return (1); diff --git a/test/test.sh b/test/test.sh index be35f684..0bcc2272 100755 --- a/test/test.sh +++ b/test/test.sh @@ -13,7 +13,10 @@ else ECHO=echo fi -touch "$TEST_OUTPUT_FILE" || exit 1 +if test "$TEST_OUTPUT_FILE" != "/dev/null" +then + touch "$TEST_OUTPUT_FILE" || exit 1 +fi TEST_DIR=. @@ -30,6 +33,7 @@ setup () { EVENT_NOSELECT=yes; export EVENT_NOSELECT EVENT_NOEPOLL=yes; export EVENT_NOEPOLL EVENT_NOEVPORT=yes; export EVENT_NOEVPORT + EVENT_NOWIN32=yes; export EVENT_NOWIN32 } announce () { @@ -120,3 +124,9 @@ unset EVENT_NOEVPORT export EVENT_NOEVPORT announce "EVPORT" run_tests + +setup +unset EVENT_NOWIN32 +export EVENT_NOWIN32 +announce "WIN32" +run_tests