blob: 25937dc6128bf46a3be9dfe1cb0ff2ee8bf54cdb [file] [log] [blame]
Roger E. Masse8ba76d31996-12-16 20:20:33 +00001#! /usr/bin/env python
2"""Test the errno module
3 Roger E. Masse
4"""
Roger E. Masse9c6db351996-12-16 20:40:20 +00005
6import errno
Barry Warsaw04f357c2002-07-23 19:04:11 +00007from test.test_support import verbose
Roger E. Masse8ba76d31996-12-16 20:20:33 +00008
9errors = ['E2BIG', 'EACCES', 'EADDRINUSE', 'EADDRNOTAVAIL', 'EADV',
Guido van Rossum41360a41998-03-26 19:42:58 +000010 'EAFNOSUPPORT', 'EAGAIN', 'EALREADY', 'EBADE', 'EBADF',
11 'EBADFD', 'EBADMSG', 'EBADR', 'EBADRQC', 'EBADSLT',
12 'EBFONT', 'EBUSY', 'ECHILD', 'ECHRNG', 'ECOMM',
13 'ECONNABORTED', 'ECONNREFUSED', 'ECONNRESET',
14 'EDEADLK', 'EDEADLOCK', 'EDESTADDRREQ', 'EDOM',
15 'EDQUOT', 'EEXIST', 'EFAULT', 'EFBIG', 'EHOSTDOWN',
16 'EHOSTUNREACH', 'EIDRM', 'EILSEQ', 'EINPROGRESS',
17 'EINTR', 'EINVAL', 'EIO', 'EISCONN', 'EISDIR',
18 'EL2HLT', 'EL2NSYNC', 'EL3HLT', 'EL3RST', 'ELIBACC',
19 'ELIBBAD', 'ELIBEXEC', 'ELIBMAX', 'ELIBSCN', 'ELNRNG',
20 'ELOOP', 'EMFILE', 'EMLINK', 'EMSGSIZE', 'EMULTIHOP',
21 'ENAMETOOLONG', 'ENETDOWN', 'ENETRESET', 'ENETUNREACH',
22 'ENFILE', 'ENOANO', 'ENOBUFS', 'ENOCSI', 'ENODATA',
23 'ENODEV', 'ENOENT', 'ENOEXEC', 'ENOLCK', 'ENOLINK',
24 'ENOMEM', 'ENOMSG', 'ENONET', 'ENOPKG', 'ENOPROTOOPT',
25 'ENOSPC', 'ENOSR', 'ENOSTR', 'ENOSYS', 'ENOTBLK',
26 'ENOTCONN', 'ENOTDIR', 'ENOTEMPTY', 'ENOTOBACCO', 'ENOTSOCK',
27 'ENOTTY', 'ENOTUNIQ', 'ENXIO', 'EOPNOTSUPP',
28 'EOVERFLOW', 'EPERM', 'EPFNOSUPPORT', 'EPIPE',
29 'EPROTO', 'EPROTONOSUPPORT', 'EPROTOTYPE',
30 'ERANGE', 'EREMCHG', 'EREMOTE', 'ERESTART',
31 'EROFS', 'ESHUTDOWN', 'ESOCKTNOSUPPORT', 'ESPIPE',
32 'ESRCH', 'ESRMNT', 'ESTALE', 'ESTRPIPE', 'ETIME',
33 'ETIMEDOUT', 'ETOOMANYREFS', 'ETXTBSY', 'EUNATCH',
34 'EUSERS', 'EWOULDBLOCK', 'EXDEV', 'EXFULL']
Roger E. Masse8ba76d31996-12-16 20:20:33 +000035
36#
Walter Dörwaldf0dfc7a2003-10-20 14:01:56 +000037# This is a wee bit bogus since the module only conditionally adds
Roger E. Masse8ba76d31996-12-16 20:20:33 +000038# errno constants if they have been defined by errno.h However, this
39# test seems to work on SGI, Sparc & intel Solaris, and linux.
40#
41for error in errors:
Guido van Rossumcee1dd31997-04-09 21:02:17 +000042 try:
Guido van Rossum41360a41998-03-26 19:42:58 +000043 a = getattr(errno, error)
Guido van Rossumcee1dd31997-04-09 21:02:17 +000044 except AttributeError:
Guido van Rossum41360a41998-03-26 19:42:58 +000045 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +000046 print('%s: not found' % error)
Guido van Rossumcee1dd31997-04-09 21:02:17 +000047 else:
Guido van Rossum41360a41998-03-26 19:42:58 +000048 if verbose:
Guido van Rossumbe19ed72007-02-09 05:37:30 +000049 print('%s: %d' % (error, a))