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 |
Roger E. Masse | fab8ab8 | 1996-12-20 22:36:52 +0000 | [diff] [blame] | 7 | from test_support import verbose |
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'), |
Roger E. Masse | 2362b58 | 1996-12-16 20:25:44 +0000 | [diff] [blame] | 12 | ] |
Roger E. Masse | 7eee08d | 1996-12-13 20:32:26 +0000 | [diff] [blame] | 13 | |
Roger E. Masse | 2362b58 | 1996-12-16 20:25:44 +0000 | [diff] [blame] | 14 | for s, func in sharedlibs: |
| 15 | try: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 16 | if verbose: |
| 17 | print 'trying to open:', s, |
| 18 | l = dl.open(s) |
Guido van Rossum | 74ee886 | 1999-02-23 17:58:48 +0000 | [diff] [blame] | 19 | except dl.error, err: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 20 | if verbose: |
Guido van Rossum | 74ee886 | 1999-02-23 17:58:48 +0000 | [diff] [blame] | 21 | print 'failed', repr(str(err)) |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 22 | pass |
Roger E. Masse | 2362b58 | 1996-12-16 20:25:44 +0000 | [diff] [blame] | 23 | else: |
Guido van Rossum | 41360a4 | 1998-03-26 19:42:58 +0000 | [diff] [blame] | 24 | if verbose: |
| 25 | print 'succeeded...', |
| 26 | l.call(func) |
| 27 | l.close() |
| 28 | if verbose: |
| 29 | print 'worked!' |
| 30 | break |
Roger E. Masse | 2362b58 | 1996-12-16 20:25:44 +0000 | [diff] [blame] | 31 | else: |
Guido van Rossum | 74ee886 | 1999-02-23 17:58:48 +0000 | [diff] [blame] | 32 | raise ImportError, 'Could not open any shared libraries' |