1996-12-13 21:32:26 +01:00
|
|
|
#! /usr/bin/env python
|
|
|
|
"""Test dlmodule.c
|
1996-12-16 21:25:44 +01:00
|
|
|
Roger E. Masse revised strategy by Barry Warsaw
|
1996-12-13 21:32:26 +01:00
|
|
|
"""
|
|
|
|
|
1996-12-16 21:25:44 +01:00
|
|
|
import dl
|
1996-12-20 23:36:52 +01:00
|
|
|
from test_support import verbose
|
1996-12-13 21:32:26 +01:00
|
|
|
|
1996-12-16 21:25:44 +01:00
|
|
|
sharedlibs = [
|
1997-04-09 22:57:52 +02:00
|
|
|
('/usr/lib/libc.so', 'getpid'),
|
1999-02-23 18:58:48 +01:00
|
|
|
('/lib/libc.so.6', 'getpid'),
|
1996-12-16 21:25:44 +01:00
|
|
|
]
|
1996-12-13 21:32:26 +01:00
|
|
|
|
1996-12-16 21:25:44 +01:00
|
|
|
for s, func in sharedlibs:
|
|
|
|
try:
|
1998-03-26 20:42:58 +01:00
|
|
|
if verbose:
|
|
|
|
print 'trying to open:', s,
|
|
|
|
l = dl.open(s)
|
1999-02-23 18:58:48 +01:00
|
|
|
except dl.error, err:
|
1998-03-26 20:42:58 +01:00
|
|
|
if verbose:
|
1999-02-23 18:58:48 +01:00
|
|
|
print 'failed', repr(str(err))
|
1998-03-26 20:42:58 +01:00
|
|
|
pass
|
1996-12-16 21:25:44 +01:00
|
|
|
else:
|
1998-03-26 20:42:58 +01:00
|
|
|
if verbose:
|
|
|
|
print 'succeeded...',
|
|
|
|
l.call(func)
|
|
|
|
l.close()
|
|
|
|
if verbose:
|
|
|
|
print 'worked!'
|
|
|
|
break
|
1996-12-16 21:25:44 +01:00
|
|
|
else:
|
1999-02-23 18:58:48 +01:00
|
|
|
raise ImportError, 'Could not open any shared libraries'
|