Blame gl/tests/test-select.h

Packit Service 4684c1
/* Test of select() substitute.
Packit Service 4684c1
   Copyright (C) 2008-2020 Free Software Foundation, Inc.
Packit Service 4684c1
Packit Service 4684c1
   This program is free software: you can redistribute it and/or modify
Packit Service 4684c1
   it under the terms of the GNU General Public License as published by
Packit Service 4684c1
   the Free Software Foundation; either version 3 of the License, or
Packit Service 4684c1
   (at your option) any later version.
Packit Service 4684c1
Packit Service 4684c1
   This program is distributed in the hope that it will be useful,
Packit Service 4684c1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4684c1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 4684c1
   GNU General Public License for more details.
Packit Service 4684c1
Packit Service 4684c1
   You should have received a copy of the GNU General Public License
Packit Service 4684c1
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit Service 4684c1
Packit Service 4684c1
/* Written by Paolo Bonzini, 2008.  */
Packit Service 4684c1
Packit Service 4684c1
#include <stdio.h>
Packit Service 4684c1
#include <string.h>
Packit Service 4684c1
#include <sys/socket.h>
Packit Service 4684c1
#include <netinet/in.h>
Packit Service 4684c1
#include <arpa/inet.h>
Packit Service 4684c1
#include <unistd.h>
Packit Service 4684c1
#include <fcntl.h>
Packit Service 4684c1
#include <stdlib.h>
Packit Service 4684c1
#include <stdbool.h>
Packit Service 4684c1
#include <sys/ioctl.h>
Packit Service 4684c1
#include <errno.h>
Packit Service 4684c1
Packit Service 4684c1
#include "macros.h"
Packit Service 4684c1
Packit Service 4684c1
#if defined _WIN32 && ! defined __CYGWIN__
Packit Service 4684c1
# define WINDOWS_NATIVE
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#ifdef HAVE_SYS_WAIT_H
Packit Service 4684c1
# include <sys/wait.h>
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#define TEST_PORT       12345
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
typedef int (*select_fn) (int, fd_set *, fd_set *, fd_set *, struct timeval *);
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* Minimal testing infrastructure.  */
Packit Service 4684c1
Packit Service 4684c1
static int failures;
Packit Service 4684c1
Packit Service 4684c1
static void
Packit Service 4684c1
failed (const char *reason)
Packit Service 4684c1
{
Packit Service 4684c1
  if (++failures > 1)
Packit Service 4684c1
    printf ("  ");
Packit Service 4684c1
  printf ("failed (%s)\n", reason);
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
static int
Packit Service 4684c1
test (void (*fn) (select_fn), select_fn my_select, const char *msg)
Packit Service 4684c1
{
Packit Service 4684c1
  failures = 0;
Packit Service 4684c1
  printf ("%s... ", msg);
Packit Service 4684c1
  fflush (stdout);
Packit Service 4684c1
  fn (my_select);
Packit Service 4684c1
Packit Service 4684c1
  if (!failures)
Packit Service 4684c1
    printf ("passed\n");
Packit Service 4684c1
Packit Service 4684c1
  return failures;
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* Funny socket code.  */
Packit Service 4684c1
Packit Service 4684c1
static int
Packit Service 4684c1
open_server_socket (void)
Packit Service 4684c1
{
Packit Service 4684c1
  int s, x;
Packit Service 4684c1
  struct sockaddr_in ia;
Packit Service 4684c1
Packit Service 4684c1
  s = socket (AF_INET, SOCK_STREAM, 0);
Packit Service 4684c1
Packit Service 4684c1
  x = 1;
Packit Service 4684c1
  setsockopt (s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x));
Packit Service 4684c1
Packit Service 4684c1
  memset (&ia, 0, sizeof (ia));
Packit Service 4684c1
  ia.sin_family = AF_INET;
Packit Service 4684c1
  inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr);
Packit Service 4684c1
  ia.sin_port = htons (TEST_PORT);
Packit Service 4684c1
  if (bind (s, (struct sockaddr *) &ia, sizeof (ia)) < 0)
Packit Service 4684c1
    {
Packit Service 4684c1
      perror ("bind");
Packit Service 4684c1
      exit (77);
Packit Service 4684c1
    }
Packit Service 4684c1
Packit Service 4684c1
  if (listen (s, 1) < 0)
Packit Service 4684c1
    {
Packit Service 4684c1
      perror ("listen");
Packit Service 4684c1
      exit (77);
Packit Service 4684c1
    }
Packit Service 4684c1
Packit Service 4684c1
  return s;
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
static int
Packit Service 4684c1
connect_to_socket (bool blocking)
Packit Service 4684c1
{
Packit Service 4684c1
  int s;
Packit Service 4684c1
  struct sockaddr_in ia;
Packit Service 4684c1
Packit Service 4684c1
  s = socket (AF_INET, SOCK_STREAM, 0);
Packit Service 4684c1
Packit Service 4684c1
  memset (&ia, 0, sizeof (ia));
Packit Service 4684c1
  ia.sin_family = AF_INET;
Packit Service 4684c1
  inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr);
Packit Service 4684c1
  ia.sin_port = htons (TEST_PORT);
Packit Service 4684c1
Packit Service 4684c1
  if (!blocking)
Packit Service 4684c1
    {
Packit Service 4684c1
#ifdef WINDOWS_NATIVE
Packit Service 4684c1
      unsigned long iMode = 1;
Packit Service 4684c1
      ioctl (s, FIONBIO, (char *) &iMode);
Packit Service 4684c1
Packit Service 4684c1
#elif defined F_GETFL
Packit Service 4684c1
      int oldflags = fcntl (s, F_GETFL, NULL);
Packit Service 4684c1
Packit Service 4684c1
      if (!(oldflags & O_NONBLOCK))
Packit Service 4684c1
        fcntl (s, F_SETFL, oldflags | O_NONBLOCK);
Packit Service 4684c1
#endif
Packit Service 4684c1
    }
Packit Service 4684c1
Packit Service 4684c1
  if (connect (s, (struct sockaddr *) &ia, sizeof (ia)) < 0
Packit Service 4684c1
      && (blocking || errno != EINPROGRESS))
Packit Service 4684c1
    {
Packit Service 4684c1
      perror ("connect");
Packit Service 4684c1
      exit (77);
Packit Service 4684c1
    }
Packit Service 4684c1
Packit Service 4684c1
  return s;
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* A slightly more convenient interface to select(2).
Packit Service 4684c1
   Waits until a specific event occurs on a file descriptor FD.
Packit Service 4684c1
   EV is a bit mask of events to look for:
Packit Service 4684c1
     SEL_IN - input can be polled without blocking,
Packit Service 4684c1
     SEL_OUT - output can be provided without blocking,
Packit Service 4684c1
     SEL_EXC - an exception occurred,
Packit Service 4684c1
   A maximum wait time is specified by TIMEOUT.
Packit Service 4684c1
   *TIMEOUT = { 0, 0 } means to return immediately,
Packit Service 4684c1
   TIMEOUT = NULL means to wait indefinitely.  */
Packit Service 4684c1
Packit Service 4684c1
enum { SEL_IN = 1, SEL_OUT = 2, SEL_EXC = 4 };
Packit Service 4684c1
Packit Service 4684c1
static int
Packit Service 4684c1
do_select (int fd, int ev, struct timeval *timeout, select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  fd_set rfds, wfds, xfds;
Packit Service 4684c1
  int r, rev;
Packit Service 4684c1
Packit Service 4684c1
  FD_ZERO (&rfds);
Packit Service 4684c1
  FD_ZERO (&wfds);
Packit Service 4684c1
  FD_ZERO (&xfds);
Packit Service 4684c1
  if (ev & SEL_IN)
Packit Service 4684c1
    FD_SET (fd, &rfds);
Packit Service 4684c1
  if (ev & SEL_OUT)
Packit Service 4684c1
    FD_SET (fd, &wfds);
Packit Service 4684c1
  if (ev & SEL_EXC)
Packit Service 4684c1
    FD_SET (fd, &xfds);
Packit Service 4684c1
  r = my_select (fd + 1, &rfds, &wfds, &xfds, timeout);
Packit Service 4684c1
  if (r < 0)
Packit Service 4684c1
    return r;
Packit Service 4684c1
Packit Service 4684c1
  rev = 0;
Packit Service 4684c1
  if (FD_ISSET (fd, &rfds))
Packit Service 4684c1
    rev |= SEL_IN;
Packit Service 4684c1
  if (FD_ISSET (fd, &wfds))
Packit Service 4684c1
    rev |= SEL_OUT;
Packit Service 4684c1
  if (FD_ISSET (fd, &xfds))
Packit Service 4684c1
    rev |= SEL_EXC;
Packit Service 4684c1
  if (rev && r == 0)
Packit Service 4684c1
    failed ("select returned 0");
Packit Service 4684c1
  if (rev & ~ev)
Packit Service 4684c1
    failed ("select returned unrequested events");
Packit Service 4684c1
Packit Service 4684c1
  return rev;
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
static int
Packit Service 4684c1
do_select_nowait (int fd, int ev, select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  struct timeval tv0;
Packit Service 4684c1
  tv0.tv_sec = 0;
Packit Service 4684c1
  tv0.tv_usec = 0;
Packit Service 4684c1
  return do_select (fd, ev, &tv0, my_select);
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
static int
Packit Service 4684c1
do_select_wait (int fd, int ev, select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  return do_select (fd, ev, NULL, my_select);
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* Test select(2) for TTYs.  */
Packit Service 4684c1
Packit Service 4684c1
#ifdef INTERACTIVE
Packit Service 4684c1
static void
Packit Service 4684c1
test_tty (select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  if (do_select_nowait (0, SEL_IN, my_select) != 0)
Packit Service 4684c1
    failed ("can read");
Packit Service 4684c1
  if (do_select_nowait (0, SEL_OUT, my_select) == 0)
Packit Service 4684c1
    failed ("cannot write");
Packit Service 4684c1
Packit Service 4684c1
  if (do_select_wait (0, SEL_IN, my_select) == 0)
Packit Service 4684c1
    failed ("return with infinite timeout");
Packit Service 4684c1
Packit Service 4684c1
  getchar ();
Packit Service 4684c1
  if (do_select_nowait (0, SEL_IN, my_select) != 0)
Packit Service 4684c1
    failed ("can read after getc");
Packit Service 4684c1
}
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
static int
Packit Service 4684c1
do_select_bad_nfd_nowait (int nfd, select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  struct timeval tv0;
Packit Service 4684c1
  tv0.tv_sec = 0;
Packit Service 4684c1
  tv0.tv_usec = 0;
Packit Service 4684c1
  errno = 0;
Packit Service 4684c1
  return my_select (nfd, NULL, NULL, NULL, &tv0);
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
static void
Packit Service 4684c1
test_bad_nfd (select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  if (do_select_bad_nfd_nowait (-1, my_select) != -1 || errno != EINVAL)
Packit Service 4684c1
    failed ("invalid errno after negative nfds");
Packit Service 4684c1
  /* Can't test FD_SETSIZE + 1 for EINVAL, since some systems allow
Packit Service 4684c1
     dynamically larger set size by redefining FD_SETSIZE anywhere up
Packit Service 4684c1
     to the actual maximum fd.  */
Packit Service 4684c1
#if 0
Packit Service 4684c1
  if (do_select_bad_nfd_nowait (FD_SETSIZE + 1, my_select) != -1
Packit Service 4684c1
      || errno != EINVAL)
Packit Service 4684c1
    failed ("invalid errno after bogus nfds");
Packit Service 4684c1
#endif
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
/* Test select(2) on invalid file descriptors.  */
Packit Service 4684c1
Packit Service 4684c1
static int
Packit Service 4684c1
do_select_bad_fd (int fd, int ev, struct timeval *timeout, select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  fd_set rfds, wfds, xfds;
Packit Service 4684c1
Packit Service 4684c1
  FD_ZERO (&rfds);
Packit Service 4684c1
  FD_ZERO (&wfds);
Packit Service 4684c1
  FD_ZERO (&xfds);
Packit Service 4684c1
  if (ev & SEL_IN)
Packit Service 4684c1
    FD_SET (fd, &rfds);
Packit Service 4684c1
  if (ev & SEL_OUT)
Packit Service 4684c1
    FD_SET (fd, &wfds);
Packit Service 4684c1
  if (ev & SEL_EXC)
Packit Service 4684c1
    FD_SET (fd, &xfds);
Packit Service 4684c1
  errno = 0;
Packit Service 4684c1
  return my_select (fd + 1, &rfds, &wfds, &xfds, timeout);
Packit Service 4684c1
  /* In this case, when fd is invalid, on some platforms, the bit for fd
Packit Service 4684c1
     is left alone in the fd_set, whereas on other platforms it is cleared.
Packit Service 4684c1
     So, don't check the bit for fd here.  */
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
static int
Packit Service 4684c1
do_select_bad_fd_nowait (int fd, int ev, select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  struct timeval tv0;
Packit Service 4684c1
  tv0.tv_sec = 0;
Packit Service 4684c1
  tv0.tv_usec = 0;
Packit Service 4684c1
  return do_select_bad_fd (fd, ev, &tv0, my_select);
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
static void
Packit Service 4684c1
test_bad_fd (select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  /* This tests fails on OSF/1 and native Windows, even with fd = 16.  */
Packit Service 4684c1
#if !(defined __osf__ || defined WINDOWS_NATIVE)
Packit Service 4684c1
  int fd;
Packit Service 4684c1
Packit Service 4684c1
  /* On Linux, Mac OS X, *BSD, values of fd like 99 or 399 are discarded
Packit Service 4684c1
     by the kernel early and therefore do *not* lead to EBADF, as required
Packit Service 4684c1
     by POSIX.  */
Packit Service 4684c1
# if defined __linux__ || (defined __APPLE__ && defined __MACH__) || (defined __FreeBSD__ || defined __DragonFly__) || defined __OpenBSD__ || defined __NetBSD__
Packit Service 4684c1
  fd = 14;
Packit Service 4684c1
# else
Packit Service 4684c1
  fd = 99;
Packit Service 4684c1
# endif
Packit Service 4684c1
  /* Even on the best POSIX compliant platforms, values of fd >= FD_SETSIZE
Packit Service 4684c1
     require an nfds argument that is > FD_SETSIZE and thus may lead to EINVAL,
Packit Service 4684c1
     not EBADF.  */
Packit Service 4684c1
  if (fd >= FD_SETSIZE)
Packit Service 4684c1
    fd = FD_SETSIZE - 1;
Packit Service 4684c1
  close (fd);
Packit Service 4684c1
Packit Service 4684c1
  if (do_select_bad_fd_nowait (fd, SEL_IN, my_select) == 0 || errno != EBADF)
Packit Service 4684c1
    failed ("invalid fd among rfds");
Packit Service 4684c1
  if (do_select_bad_fd_nowait (fd, SEL_OUT, my_select) == 0 || errno != EBADF)
Packit Service 4684c1
    failed ("invalid fd among wfds");
Packit Service 4684c1
  if (do_select_bad_fd_nowait (fd, SEL_EXC, my_select) == 0 || errno != EBADF)
Packit Service 4684c1
    failed ("invalid fd among xfds");
Packit Service 4684c1
#endif
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* Test select(2) for unconnected nonblocking sockets.  */
Packit Service 4684c1
Packit Service 4684c1
static void
Packit Service 4684c1
test_connect_first (select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  int s = open_server_socket ();
Packit Service 4684c1
  struct sockaddr_in ia;
Packit Service 4684c1
  socklen_t addrlen;
Packit Service 4684c1
Packit Service 4684c1
  int c1, c2;
Packit Service 4684c1
Packit Service 4684c1
  if (do_select_nowait (s, SEL_IN | SEL_EXC, my_select) != 0)
Packit Service 4684c1
    failed ("can read, socket not connected");
Packit Service 4684c1
Packit Service 4684c1
  c1 = connect_to_socket (false);
Packit Service 4684c1
Packit Service 4684c1
  if (do_select_wait (s, SEL_IN | SEL_EXC, my_select) != SEL_IN)
Packit Service 4684c1
    failed ("expecting readability on passive socket");
Packit Service 4684c1
  if (do_select_nowait (s, SEL_IN | SEL_EXC, my_select) != SEL_IN)
Packit Service 4684c1
    failed ("expecting readability on passive socket");
Packit Service 4684c1
Packit Service 4684c1
  addrlen = sizeof (ia);
Packit Service 4684c1
  c2 = accept (s, (struct sockaddr *) &ia, &addrlen);
Packit Service 4684c1
  ASSERT (close (s) == 0);
Packit Service 4684c1
  ASSERT (close (c1) == 0);
Packit Service 4684c1
  ASSERT (close (c2) == 0);
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* Test select(2) for unconnected blocking sockets.  */
Packit Service 4684c1
Packit Service 4684c1
static void
Packit Service 4684c1
test_accept_first (select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
#ifndef WINDOWS_NATIVE
Packit Service 4684c1
  int s = open_server_socket ();
Packit Service 4684c1
  struct sockaddr_in ia;
Packit Service 4684c1
  socklen_t addrlen;
Packit Service 4684c1
  char buf[3];
Packit Service 4684c1
  int c, pid;
Packit Service 4684c1
Packit Service 4684c1
  pid = fork ();
Packit Service 4684c1
  if (pid < 0)
Packit Service 4684c1
    return;
Packit Service 4684c1
Packit Service 4684c1
  if (pid == 0)
Packit Service 4684c1
    {
Packit Service 4684c1
      addrlen = sizeof (ia);
Packit Service 4684c1
      c = accept (s, (struct sockaddr *) &ia, &addrlen);
Packit Service 4684c1
      ASSERT (close (s) == 0);
Packit Service 4684c1
      ASSERT (write (c, "foo", 3) == 3);
Packit Service 4684c1
      ASSERT (read (c, buf, 3) == 3);
Packit Service 4684c1
      shutdown (c, SHUT_RD);
Packit Service 4684c1
      ASSERT (close (c) == 0);
Packit Service 4684c1
      exit (0);
Packit Service 4684c1
    }
Packit Service 4684c1
  else
Packit Service 4684c1
    {
Packit Service 4684c1
      ASSERT (close (s) == 0);
Packit Service 4684c1
      c = connect_to_socket (true);
Packit Service 4684c1
      if (do_select_nowait (c, SEL_OUT, my_select) != SEL_OUT)
Packit Service 4684c1
        failed ("cannot write after blocking connect");
Packit Service 4684c1
      ASSERT (write (c, "foo", 3) == 3);
Packit Service 4684c1
      wait (&pid;;
Packit Service 4684c1
      if (do_select_wait (c, SEL_IN, my_select) != SEL_IN)
Packit Service 4684c1
        failed ("cannot read data left in the socket by closed process");
Packit Service 4684c1
      ASSERT (read (c, buf, 3) == 3);
Packit Service 4684c1
      ASSERT (write (c, "foo", 3) == 3);
Packit Service 4684c1
      (void) close (c); /* may fail with errno = ECONNRESET */
Packit Service 4684c1
    }
Packit Service 4684c1
#endif
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* Common code for pipes and connected sockets.  */
Packit Service 4684c1
Packit Service 4684c1
static void
Packit Service 4684c1
test_pair (int rd, int wd, select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  char buf[3];
Packit Service 4684c1
  if (do_select_wait (wd, SEL_IN | SEL_OUT | SEL_EXC, my_select) != SEL_OUT)
Packit Service 4684c1
    failed ("expecting writability before writing");
Packit Service 4684c1
  if (do_select_nowait (wd, SEL_IN | SEL_OUT | SEL_EXC, my_select) != SEL_OUT)
Packit Service 4684c1
    failed ("expecting writability before writing");
Packit Service 4684c1
Packit Service 4684c1
  ASSERT (write (wd, "foo", 3) == 3);
Packit Service 4684c1
  if (do_select_wait (rd, SEL_IN, my_select) != SEL_IN)
Packit Service 4684c1
    failed ("expecting readability after writing");
Packit Service 4684c1
  if (do_select_nowait (rd, SEL_IN, my_select) != SEL_IN)
Packit Service 4684c1
    failed ("expecting readability after writing");
Packit Service 4684c1
Packit Service 4684c1
  ASSERT (read (rd, buf, 3) == 3);
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* Test select(2) on connected sockets.  */
Packit Service 4684c1
Packit Service 4684c1
static void
Packit Service 4684c1
test_socket_pair (select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  struct sockaddr_in ia;
Packit Service 4684c1
Packit Service 4684c1
  socklen_t addrlen = sizeof (ia);
Packit Service 4684c1
  int s = open_server_socket ();
Packit Service 4684c1
  int c1 = connect_to_socket (false);
Packit Service 4684c1
  int c2 = accept (s, (struct sockaddr *) &ia, &addrlen);
Packit Service 4684c1
Packit Service 4684c1
  ASSERT (close (s) == 0);
Packit Service 4684c1
Packit Service 4684c1
  test_pair (c1, c2, my_select);
Packit Service 4684c1
  ASSERT (close (c1) == 0);
Packit Service 4684c1
  ASSERT (write (c2, "foo", 3) == 3);
Packit Service 4684c1
  (void) close (c2); /* may fail with errno = ECONNRESET */
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* Test select(2) on pipes.  */
Packit Service 4684c1
Packit Service 4684c1
static void
Packit Service 4684c1
test_pipe (select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  int fd[2];
Packit Service 4684c1
Packit Service 4684c1
  ASSERT (pipe (fd) == 0);
Packit Service 4684c1
  test_pair (fd[0], fd[1], my_select);
Packit Service 4684c1
  ASSERT (close (fd[0]) == 0);
Packit Service 4684c1
  ASSERT (close (fd[1]) == 0);
Packit Service 4684c1
}
Packit Service 4684c1
Packit Service 4684c1
Packit Service 4684c1
/* Do them all.  */
Packit Service 4684c1
Packit Service 4684c1
static int
Packit Service 4684c1
test_function (select_fn my_select)
Packit Service 4684c1
{
Packit Service 4684c1
  int result = 0;
Packit Service 4684c1
Packit Service 4684c1
#ifdef INTERACTIVE
Packit Service 4684c1
  printf ("Please press Enter\n");
Packit Service 4684c1
  test (test_tty, "TTY", my_select);
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
  result += test (test_bad_nfd, my_select, "Invalid nfd test");
Packit Service 4684c1
  result += test (test_bad_fd, my_select, "Invalid fd test");
Packit Service 4684c1
  result += test (test_connect_first, my_select, "Unconnected socket test");
Packit Service 4684c1
  result += test (test_socket_pair, my_select, "Connected sockets test");
Packit Service 4684c1
  result += test (test_accept_first, my_select, "General socket test with fork");
Packit Service 4684c1
  result += test (test_pipe, my_select, "Pipe test");
Packit Service 4684c1
Packit Service 4684c1
  return result;
Packit Service 4684c1
}