projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
getlogin_r: Support for native Windows.
[gnulib.git]
/
tests
/
test-poll.c
diff --git
a/tests/test-poll.c
b/tests/test-poll.c
index
1f66a63
..
7488090
100644
(file)
--- a/
tests/test-poll.c
+++ b/
tests/test-poll.c
@@
-1,5
+1,5
@@
/* Test of poll() function.
/* Test of poll() function.
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008
-2010
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-19,19
+19,27
@@
#include <config.h>
#include <config.h>
+#include <poll.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (poll, int, (struct pollfd[], nfds_t, int));
+
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <poll.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdbool.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdbool.h>
+#include <sys/ioctl.h>
#include <errno.h>
#include <errno.h>
-#include "sockets.h"
-#ifdef __MSVCRT__
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# define WIN32_NATIVE
+#endif
+
+#ifdef WIN32_NATIVE
#include <io.h>
#define pipe(x) _pipe(x, 256, O_BINARY)
#endif
#include <io.h>
#define pipe(x) _pipe(x, 256, O_BINARY)
#endif
@@
-46,7
+54,7
@@
#define SO_REUSEPORT SO_REUSEADDR
#endif
#define SO_REUSEPORT SO_REUSEADDR
#endif
-#define TEST_PORT 12345
+#define TEST_PORT
12345
/* Minimal testing infrastructure. */
/* Minimal testing infrastructure. */
@@
-123,28
+131,24
@@
connect_to_socket (int blocking)
if (!blocking)
{
if (!blocking)
{
-#ifdef
__MSVCRT__
+#ifdef
WIN32_NATIVE
unsigned long iMode = 1;
unsigned long iMode = 1;
- ioctl
socket (s, FIONBIO, (void
*) &iMode);
-
+ ioctl
(s, FIONBIO, (char
*) &iMode);
+
#elif defined F_GETFL
int oldflags = fcntl (s, F_GETFL, NULL);
#elif defined F_GETFL
int oldflags = fcntl (s, F_GETFL, NULL);
-
+
if (!(oldflags & O_NONBLOCK))
fcntl (s, F_SETFL, oldflags | O_NONBLOCK);
#endif
}
if (!(oldflags & O_NONBLOCK))
fcntl (s, F_SETFL, oldflags | O_NONBLOCK);
#endif
}
- if (connect (s, (struct sockaddr *) &ia, sizeof (ia)) < 0)
+ if (connect (s, (struct sockaddr *) &ia, sizeof (ia)) < 0
+ && (blocking || errno != EINPROGRESS))
{
{
- if (errno != EINPROGRESS)
- {
- perror ("connect");
- exit (77);
- }
+ perror ("connect");
+ exit (77);
}
}
- else if (!blocking)
- failed ("huh, connect succeeded?");
return s;
}
return s;
}
@@
-161,7
+165,7
@@
poll1 (int fd, int ev, int time)
pfd.fd = fd;
pfd.events = ev;
pfd.revents = 0;
pfd.fd = fd;
pfd.events = ev;
pfd.revents = 0;
- r = poll (&pfd, 1, time);
+ r = poll (&pfd, 1, time);
if (r < 0)
return r;
if (r < 0)
return r;
@@
-241,7
+245,7
@@
test_connect_first (void)
static void
test_accept_first (void)
{
static void
test_accept_first (void)
{
-#ifndef
__MSVCRT__
+#ifndef
WIN32_NATIVE
int s = open_server_socket ();
struct sockaddr_in ia;
socklen_t addrlen;
int s = open_server_socket ();
struct sockaddr_in ia;
socklen_t addrlen;
@@
-268,7
+272,7
@@
test_accept_first (void)
close (s);
c = connect_to_socket (true);
if (poll1_nowait (c, POLLOUT | POLLWRNORM | POLLRDBAND)
close (s);
c = connect_to_socket (true);
if (poll1_nowait (c, POLLOUT | POLLWRNORM | POLLRDBAND)
- != (POLLOUT | POLLWRNORM))
+
!= (POLLOUT | POLLWRNORM))
failed ("cannot write after blocking connect");
write (c, "foo", 3);
wait (&pid);
failed ("cannot write after blocking connect");
write (c, "foo", 3);
wait (&pid);
@@
-359,8
+363,6
@@
main ()
{
int result;
{
int result;
- gl_sockets_startup (SOCKETS_2_0);
-
#ifdef INTERACTIVE
printf ("Please press Enter\n");
test (test_tty, "TTY");
#ifdef INTERACTIVE
printf ("Please press Enter\n");
test (test_tty, "TTY");