1"""Test dlmodule.c 2 Roger E. Masse revised strategy by Barry Warsaw 3""" 4import unittest 5from test.test_support import verbose, import_module 6dl = import_module('dl', deprecated=True) 7 8sharedlibs = [ 9 ('/usr/lib/libc.so', 'getpid'), 10 ('/lib/libc.so.6', 'getpid'), 11 ('/usr/bin/cygwin1.dll', 'getpid'), 12 ('/usr/lib/libc.dylib', 'getpid'), 13 ] 14 15def test_main(): 16 for s, func in sharedlibs: 17 try: 18 if verbose: 19 print 'trying to open:', s, 20 l = dl.open(s) 21 except dl.error, err: 22 if verbose: 23 print 'failed', repr(str(err)) 24 pass 25 else: 26 if verbose: 27 print 'succeeded...', 28 l.call(func) 29 l.close() 30 if verbose: 31 print 'worked!' 32 break 33 else: 34 raise unittest.SkipTest, 'Could not open any shared libraries' 35 36 37if __name__ == '__main__': 38 test_main() 39