Merge tag 'snapshot-start' into stable
[gnulib.git] / tests / test-select.h
index 85c561a..9fe998c 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of select() substitute.
-   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Copyright (C) 2008-2012 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
@@ -30,7 +30,7 @@
 #include "macros.h"
 
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# define WIN32_NATIVE
+# define WINDOWS_NATIVE
 #endif
 
 #ifdef HAVE_SYS_WAIT_H
@@ -121,7 +121,7 @@ connect_to_socket (bool blocking)
 
   if (!blocking)
     {
-#ifdef WIN32_NATIVE
+#ifdef WINDOWS_NATIVE
       unsigned long iMode = 1;
       ioctl (s, FIONBIO, (char *) &iMode);
 
@@ -261,16 +261,18 @@ do_select_bad_fd_nowait (int fd, int ev, select_fn my_select)
 static void
 test_bad_fd (select_fn my_select)
 {
+  /* This tests fails on OSF/1 and native Windows, even with fd = 16.  */
+#if !(defined __osf__ || defined WINDOWS_NATIVE)
   int fd;
 
-  /* On Linux, MacOS X, *BSD, and OSF/1, values of fd like 99 or 399 are
-     discarded by the kernel early and therefore do *not* lead to EBADF,
-     as required by POSIX.  */
-#if defined __linux__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ || defined __osf__
+  /* On Linux, MacOS X, *BSD, values of fd like 99 or 399 are discarded
+     by the kernel early and therefore do *not* lead to EBADF, as required
+     by POSIX.  */
+# if defined __linux__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__
   fd = 16;
-#else
+# else
   fd = 99;
-#endif
+# endif
 
   if (do_select_bad_fd_nowait (fd, SEL_IN, my_select) == 0 || errno != EBADF)
     failed ("invalid fd among rfds");
@@ -278,6 +280,7 @@ test_bad_fd (select_fn my_select)
     failed ("invalid fd among wfds");
   if (do_select_bad_fd_nowait (fd, SEL_EXC, my_select) == 0 || errno != EBADF)
     failed ("invalid fd among xfds");
+#endif
 }
 
 
@@ -315,7 +318,7 @@ test_connect_first (select_fn my_select)
 static void
 test_accept_first (select_fn my_select)
 {
-#ifndef WIN32_NATIVE
+#ifndef WINDOWS_NATIVE
   int s = open_server_socket ();
   struct sockaddr_in ia;
   socklen_t addrlen;