Roger E. Masse | 7eee08d | 1996-12-13 20:32:26 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | """Test dlmodule.c |
Roger E. Masse | 2362b58 | 1996-12-16 20:25:44 +0000 | [diff] [blame] | 3 | Roger E. Masse revised strategy by Barry Warsaw |
Roger E. Masse | 7eee08d | 1996-12-13 20:32:26 +0000 | [diff] [blame] | 4 | """ |
Roger E. Masse | 7eee08d | 1996-12-13 20:32:26 +0000 | [diff] [blame] | 5 | |
Roger E. Masse | 2362b58 | 1996-12-16 20:25:44 +0000 | [diff] [blame] | 6 | import dl |
Barry Warsaw | 04f357c | 2002-07-23 19:04:11 +0000 | [diff] [blame] | 7 | from test.test_support import verbose,TestSkipped |
Roger E. Masse | 7eee08d | 1996-12-13 20:32:26 +0000 | [diff] [blame] | 8 | |
Roger E. Masse | 2362b58 | 1996-12-16 20:25:44 +0000 | [diff] [blame] | 9 | sharedlibs = [ |
Guido van Rossum | a6ed225 | 1997-04-09 20:57:52 +0000 | [diff] [blame] | 10 | ('/usr/lib/libc.so', 'getpid'), |
Guido van Rossum | 74ee886 | 1999-02-23 17:58:48 +0000 | [diff] [blame] | 11 | ('/lib/libc.so.6', 'getpid'), |
Andrew M. Kuchling | 6efc6e7 | 2001-02-27 20:54:23 +0000 | [diff] [blame] | 12 | ('/usr/bin/cygwin1.dll', 'getpid'), |
Roger E. Masse | 2362b58 | 1996-12-16 20:25:44 +0000 | [diff] [blame] | 13 | ] |
Roger E. Masse | 7eee08d | 1996-12-13 20:32:26 +0000 | [diff] [blame] | 14 | |
Roger E. Masse | 2362b58 | 1996-12-16 20:25:44 +0000 | [diff] [blame] | 15 | for s, func in sharedlibs: |
| 16 | try: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 17 | if verbose: |
| 18 | print 'trying to open:', s, |
| 19 | l = dl.open(s) |
Guido van Rossum | 74ee886 | 1999-02-23 17:58:48 +0000 | [diff] [blame] | 20 | except dl.error, err: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 21 | if verbose: |
Guido van Rossum | 74ee886 | 1999-02-23 17:58:48 +0000 | [diff] [blame] | 22 | print 'failed', repr(str(err)) |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 23 | pass |
Roger E. Masse | 2362b58 | 1996-12-16 20:25:44 +0000 | [diff] [blame] | 24 | else: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 25 | if verbose: |
| 26 | print 'succeeded...', |
| 27 | l.call(func) |
| 28 | l.close() |
| 29 | if verbose: |
| 30 | print 'worked!' |
| 31 | break |
Roger E. Masse | 2362b58 | 1996-12-16 20:25:44 +0000 | [diff] [blame] | 32 | else: |
Thomas Wouters | b9fa0a8 | 2000-08-04 13:34:43 +0000 | [diff] [blame] | 33 | raise TestSkipped, 'Could not open any shared libraries' |