Blame gnulib-tests/test-errno.c

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