Roger E. Masse | 8ba76d3 | 1996-12-16 20:20:33 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | """Test the errno module |
| 3 | Roger E. Masse |
| 4 | """ |
Roger E. Masse | 9c6db35 | 1996-12-16 20:40:20 +0000 | [diff] [blame] | 5 | |
| 6 | import errno |
Roger E. Masse | fab8ab8 | 1996-12-20 22:36:52 +0000 | [diff] [blame] | 7 | from test_support import verbose |
Roger E. Masse | 8ba76d3 | 1996-12-16 20:20:33 +0000 | [diff] [blame] | 8 | |
| 9 | errors = ['E2BIG', 'EACCES', 'EADDRINUSE', 'EADDRNOTAVAIL', 'EADV', |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 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', |
| 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. Masse | 8ba76d3 | 1996-12-16 20:20:33 +0000 | [diff] [blame] | 35 | |
| 36 | # |
Roger E. Masse | fab8ab8 | 1996-12-20 22:36:52 +0000 | [diff] [blame] | 37 | # This is is a wee bit bogus since the module only conditionally adds |
Roger E. Masse | 8ba76d3 | 1996-12-16 20:20:33 +0000 | [diff] [blame] | 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 | cee1dd3 | 1997-04-09 21:02:17 +0000 | [diff] [blame] | 42 | try: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 43 | a = getattr(errno, error) |
Guido van Rossum | cee1dd3 | 1997-04-09 21:02:17 +0000 | [diff] [blame] | 44 | except AttributeError: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 45 | if verbose: |
| 46 | print '%s: not found' % error |
Guido van Rossum | cee1dd3 | 1997-04-09 21:02:17 +0000 | [diff] [blame] | 47 | else: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 48 | if verbose: |
| 49 | print '%s: %d' % (error, a) |