1996-12-13 16:32:26 -04:00
|
|
|
#! /usr/bin/env python
|
|
|
|
"""Test dlmodule.c
|
1996-12-16 16:25:44 -04:00
|
|
|
Roger E. Masse revised strategy by Barry Warsaw
|
1996-12-13 16:32:26 -04:00
|
|
|
"""
|
2008-05-10 18:20:19 -03:00
|
|
|
from test.test_support import verbose,TestSkipped, import_module
|
|
|
|
dl = import_module('dl', deprecated=True)
|
1996-12-13 16:32:26 -04:00
|
|
|
|
1996-12-16 16:25:44 -04:00
|
|
|
sharedlibs = [
|
1997-04-09 17:57:52 -03:00
|
|
|
('/usr/lib/libc.so', 'getpid'),
|
1999-02-23 13:58:48 -04:00
|
|
|
('/lib/libc.so.6', 'getpid'),
|
2001-02-27 16:54:23 -04:00
|
|
|
('/usr/bin/cygwin1.dll', 'getpid'),
|
2006-04-09 12:07:40 -03:00
|
|
|
('/usr/lib/libc.dylib', 'getpid'),
|
1996-12-16 16:25:44 -04:00
|
|
|
]
|
1996-12-13 16:32:26 -04:00
|
|
|
|
2008-04-01 09:46:02 -03:00
|
|
|
def test_main():
|
|
|
|
for s, func in sharedlibs:
|
|
|
|
try:
|
|
|
|
if verbose:
|
|
|
|
print 'trying to open:', s,
|
|
|
|
l = dl.open(s)
|
|
|
|
except dl.error, err:
|
|
|
|
if verbose:
|
|
|
|
print 'failed', repr(str(err))
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
if verbose:
|
|
|
|
print 'succeeded...',
|
|
|
|
l.call(func)
|
|
|
|
l.close()
|
|
|
|
if verbose:
|
|
|
|
print 'worked!'
|
|
|
|
break
|
1996-12-16 16:25:44 -04:00
|
|
|
else:
|
2008-04-01 09:46:02 -03:00
|
|
|
raise TestSkipped, 'Could not open any shared libraries'
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
test_main()
|