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
This commit is contained in:
Nick Mathewson 2010-05-08 18:00:26 -04:00
parent 935e1504b1
commit 0ee6f6ce80
5 changed files with 51 additions and 2 deletions

View 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);

View File

@ -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();

View 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();

View 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);

View File

@ -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