Guido van Rossum | 228b8e8 | 1997-04-02 06:13:34 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | """Test the errno module |
| 3 | Roger E. Masse |
| 4 | """ |
| 5 | |
| 6 | import errno |
| 7 | from test_support import verbose |
| 8 | |
| 9 | errors = ['E2BIG', 'EACCES', 'EADDRINUSE', 'EADDRNOTAVAIL', 'EADV', |
| 10 | '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', |
Guido van Rossum | de554ec | 1997-05-08 23:14:57 +0000 | [diff] [blame] | 26 | 'ENOTCONN', 'ENOTDIR', 'ENOTEMPTY', 'ENOTOBACCO', 'ENOTSOCK', |
Guido van Rossum | 228b8e8 | 1997-04-02 06:13:34 +0000 | [diff] [blame] | 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'] |
| 35 | |
| 36 | # |
| 37 | # This is is a wee bit bogus since the module only conditionally adds |
| 38 | # 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 | # |
| 41 | for error in errors: |
Guido van Rossum | de554ec | 1997-05-08 23:14:57 +0000 | [diff] [blame] | 42 | try: |
| 43 | a = getattr(errno, error) |
| 44 | except AttributeError: |
| 45 | if verbose: |
| 46 | print '%s: not found' % error |
| 47 | else: |
| 48 | if verbose: |
| 49 | print '%s: %d' % (error, a) |