Blame gnulib-tests/test-ioctl.c

Packit Service 2723c6
/* Test of ioctl() function.
Packit Service 2723c6
   Copyright (C) 2011-2018 Free Software Foundation, Inc.
Packit Service 2723c6
Packit Service 2723c6
   This program is free software: you can redistribute it and/or modify
Packit Service 2723c6
   it under the terms of the GNU General Public License as published by
Packit Service 2723c6
   the Free Software Foundation; either version 3 of the License, or
Packit Service 2723c6
   (at your option) any later version.
Packit Service 2723c6
Packit Service 2723c6
   This program is distributed in the hope that it will be useful,
Packit Service 2723c6
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 2723c6
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 2723c6
   GNU General Public License for more details.
Packit Service 2723c6
Packit Service 2723c6
   You should have received a copy of the GNU General Public License
Packit Service 2723c6
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit Service 2723c6
Packit Service 2723c6
#include <config.h>
Packit Service 2723c6
Packit Service 2723c6
/* Specification.  */
Packit Service 2723c6
#include <sys/ioctl.h>
Packit Service 2723c6
Packit Service 2723c6
#include "signature.h"
Packit Service 2723c6
SIGNATURE_CHECK (ioctl, int, (int, int, ...));
Packit Service 2723c6
Packit Service 2723c6
#include <errno.h>
Packit Service 2723c6
#include <unistd.h>
Packit Service 2723c6
Packit Service 2723c6
#include "macros.h"
Packit Service 2723c6
Packit Service 2723c6
int
Packit Service 2723c6
main (void)
Packit Service 2723c6
{
Packit Service 2723c6
#ifdef FIONREAD
Packit Service 2723c6
  /* Test behaviour for invalid file descriptors.  */
Packit Service 2723c6
  {
Packit Service 2723c6
    int value;
Packit Service 2723c6
    errno = 0;
Packit Service 2723c6
    ASSERT (ioctl (-1, FIONREAD, &value) == -1);
Packit Service 2723c6
    ASSERT (errno == EBADF);
Packit Service 2723c6
  }
Packit Service 2723c6
  {
Packit Service 2723c6
    int value;
Packit Service 2723c6
    close (99);
Packit Service 2723c6
    errno = 0;
Packit Service 2723c6
    ASSERT (ioctl (99, FIONREAD, &value) == -1);
Packit Service 2723c6
    ASSERT (errno == EBADF);
Packit Service 2723c6
  }
Packit Service 2723c6
#endif
Packit Service 2723c6
Packit Service 2723c6
  return 0;
Packit Service 2723c6
}