Blame gnulib-tests/test-errno.c

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