]> granicus.if.org Git - libevent/commitdiff
Make test.sh support mingw/msys on win32
authorNick Mathewson <nickm@torproject.org>
Sat, 8 May 2010 22:00:26 +0000 (18:00 -0400)
committerNick Mathewson <nickm@torproject.org>
Sat, 8 May 2010 23:38:30 +0000 (19:38 -0400)
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

test/test-eof.c
test/test-init.c
test/test-time.c
test/test-weof.c
test/test.sh

index a5933c512d953bac2f4a5c0e1b77b035ff8fc7d1..001370a8c58eea33b71260d583cc3a654fd3817c 100644 (file)
@@ -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);
 
index 68ad561ac5db34f201f44664e001683a339d01c8..3806c15d4d0ccf2396bcc0f84a554e3e4f81a70d 100644 (file)
 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();
 
index c1b449b2a927ad1d87c6ce1b4d41fcbd1e5cb52f..24daf8c84985d29d54b1d65372fa84327c9ca323 100644 (file)
@@ -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();
index e5ff99d2010d052b288e371abe07471907f44467..946d3a0b4bdc42950d76b1c1d3b67ca50147ebde 100644 (file)
@@ -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);
index be35f68436792858d5a9781c16b3fa2028997ef0..0bcc22727c7be8f32e5415aa2ae4a0ac50aed452 100755 (executable)
@@ -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