Blame gl/tests/test-errno.c

Packit aea12f
/* Test of <errno.h> substitute.
Packit Service 991b93
   Copyright (C) 2008-2020 Free Software Foundation, Inc.
Packit aea12f
Packit aea12f
   This program is free software: you can redistribute it and/or modify
Packit aea12f
   it under the terms of the GNU General Public License as published by
Packit aea12f
   the Free Software Foundation; either version 3 of the License, or
Packit aea12f
   (at your option) any later version.
Packit aea12f
Packit aea12f
   This program is distributed in the hope that it will be useful,
Packit aea12f
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit aea12f
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit aea12f
   GNU General Public License for more details.
Packit aea12f
Packit aea12f
   You should have received a copy of the GNU General Public License
Packit aea12f
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit aea12f
Packit aea12f
/* Written by Bruno Haible <bruno@clisp.org>, 2008.  */
Packit aea12f
Packit aea12f
#include <config.h>
Packit aea12f
Packit aea12f
#include <errno.h>
Packit aea12f
Packit aea12f
/* Verify that the POSIX mandated errno values exist and can be used as
Packit aea12f
   initializers outside of a function.
Packit aea12f
   The variable names happen to match the Linux/x86 error numbers.  */
Packit aea12f
int e1 = EPERM;
Packit aea12f
int e2 = ENOENT;
Packit aea12f
int e3 = ESRCH;
Packit aea12f
int e4 = EINTR;
Packit aea12f
int e5 = EIO;
Packit aea12f
int e6 = ENXIO;
Packit aea12f
int e7 = E2BIG;
Packit aea12f
int e8 = ENOEXEC;
Packit aea12f
int e9 = EBADF;
Packit aea12f
int e10 = ECHILD;
Packit aea12f
int e11 = EAGAIN;
Packit aea12f
int e11a = EWOULDBLOCK;
Packit aea12f
int e12 = ENOMEM;
Packit aea12f
int e13 = EACCES;
Packit aea12f
int e14 = EFAULT;
Packit aea12f
int e16 = EBUSY;
Packit aea12f
int e17 = EEXIST;
Packit aea12f
int e18 = EXDEV;
Packit aea12f
int e19 = ENODEV;
Packit aea12f
int e20 = ENOTDIR;
Packit aea12f
int e21 = EISDIR;
Packit aea12f
int e22 = EINVAL;
Packit aea12f
int e23 = ENFILE;
Packit aea12f
int e24 = EMFILE;
Packit aea12f
int e25 = ENOTTY;
Packit aea12f
int e26 = ETXTBSY;
Packit aea12f
int e27 = EFBIG;
Packit aea12f
int e28 = ENOSPC;
Packit aea12f
int e29 = ESPIPE;
Packit aea12f
int e30 = EROFS;
Packit aea12f
int e31 = EMLINK;
Packit aea12f
int e32 = EPIPE;
Packit aea12f
int e33 = EDOM;
Packit aea12f
int e34 = ERANGE;
Packit aea12f
int e35 = EDEADLK;
Packit aea12f
int e36 = ENAMETOOLONG;
Packit aea12f
int e37 = ENOLCK;
Packit aea12f
int e38 = ENOSYS;
Packit aea12f
int e39 = ENOTEMPTY;
Packit aea12f
int e40 = ELOOP;
Packit aea12f
int e42 = ENOMSG;
Packit aea12f
int e43 = EIDRM;
Packit aea12f
int e67 = ENOLINK;
Packit aea12f
int e71 = EPROTO;
Packit aea12f
int e72 = EMULTIHOP;
Packit aea12f
int e74 = EBADMSG;
Packit aea12f
int e75 = EOVERFLOW;
Packit aea12f
int e84 = EILSEQ;
Packit aea12f
int e88 = ENOTSOCK;
Packit aea12f
int e89 = EDESTADDRREQ;
Packit aea12f
int e90 = EMSGSIZE;
Packit aea12f
int e91 = EPROTOTYPE;
Packit aea12f
int e92 = ENOPROTOOPT;
Packit aea12f
int e93 = EPROTONOSUPPORT;
Packit aea12f
int e95 = EOPNOTSUPP;
Packit aea12f
int e95a = ENOTSUP;
Packit aea12f
int e97 = EAFNOSUPPORT;
Packit aea12f
int e98 = EADDRINUSE;
Packit aea12f
int e99 = EADDRNOTAVAIL;
Packit aea12f
int e100 = ENETDOWN;
Packit aea12f
int e101 = ENETUNREACH;
Packit aea12f
int e102 = ENETRESET;
Packit aea12f
int e103 = ECONNABORTED;
Packit aea12f
int e104 = ECONNRESET;
Packit aea12f
int e105 = ENOBUFS;
Packit aea12f
int e106 = EISCONN;
Packit aea12f
int e107 = ENOTCONN;
Packit aea12f
int e110 = ETIMEDOUT;
Packit aea12f
int e111 = ECONNREFUSED;
Packit aea12f
int e113 = EHOSTUNREACH;
Packit aea12f
int e114 = EALREADY;
Packit aea12f
int e115 = EINPROGRESS;
Packit aea12f
int e116 = ESTALE;
Packit aea12f
int e122 = EDQUOT;
Packit aea12f
int e125 = ECANCELED;
Packit aea12f
int e130 = EOWNERDEAD;
Packit aea12f
int e131 = ENOTRECOVERABLE;
Packit aea12f
Packit aea12f
/* Don't verify that these errno values are all different, except for possibly
Packit aea12f
   EWOULDBLOCK == EAGAIN.  Even Linux/x86 does not pass this check: it has
Packit aea12f
   ENOTSUP == EOPNOTSUPP.  */
Packit aea12f
Packit aea12f
int
Packit aea12f
main ()
Packit aea12f
{
Packit aea12f
  /* Verify that errno can be assigned.  */
Packit aea12f
  errno = EOVERFLOW;
Packit aea12f
Packit aea12f
  /* snprintf() callers want to distinguish EINVAL and EOVERFLOW.  */
Packit aea12f
  if (errno == EINVAL)
Packit aea12f
    return 1;
Packit aea12f
Packit aea12f
  return 0;
Packit aea12f
}