blob: cb1e729f8ec0aa36245df0d8c1106c4a581ea507 [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
Roger E. Massefab8ab81996-12-20 22:36:52 +00007from 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#
Roger E. Massefab8ab81996-12-20 22:36:52 +000037# This is 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:
46 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:
49 print '%s: %d' % (error, a)