blob: d1f73b2e04ced9dad9722d9acd319f58ad411169 [file] [log] [blame]
Roger E. Masse7eee08d1996-12-13 20:32:26 +00001#! /usr/bin/env python
2"""Test dlmodule.c
Roger E. Masse2362b581996-12-16 20:25:44 +00003 Roger E. Masse revised strategy by Barry Warsaw
Roger E. Masse7eee08d1996-12-13 20:32:26 +00004"""
Roger E. Masse7eee08d1996-12-13 20:32:26 +00005
Roger E. Masse2362b581996-12-16 20:25:44 +00006import dl
Barry Warsaw04f357c2002-07-23 19:04:11 +00007from test.test_support import verbose,TestSkipped
Roger E. Masse7eee08d1996-12-13 20:32:26 +00008
Roger E. Masse2362b581996-12-16 20:25:44 +00009sharedlibs = [
Guido van Rossuma6ed2251997-04-09 20:57:52 +000010 ('/usr/lib/libc.so', 'getpid'),
Guido van Rossum74ee8861999-02-23 17:58:48 +000011 ('/lib/libc.so.6', 'getpid'),
Andrew M. Kuchling6efc6e72001-02-27 20:54:23 +000012 ('/usr/bin/cygwin1.dll', 'getpid'),
Roger E. Masse2362b581996-12-16 20:25:44 +000013 ]
Roger E. Masse7eee08d1996-12-13 20:32:26 +000014
Roger E. Masse2362b581996-12-16 20:25:44 +000015for s, func in sharedlibs:
16 try:
Guido van Rossum41360a41998-03-26 19:42:58 +000017 if verbose:
18 print 'trying to open:', s,
19 l = dl.open(s)
Guido van Rossum74ee8861999-02-23 17:58:48 +000020 except dl.error, err:
Guido van Rossum41360a41998-03-26 19:42:58 +000021 if verbose:
Guido van Rossum74ee8861999-02-23 17:58:48 +000022 print 'failed', repr(str(err))
Guido van Rossum41360a41998-03-26 19:42:58 +000023 pass
Roger E. Masse2362b581996-12-16 20:25:44 +000024 else:
Guido van Rossum41360a41998-03-26 19:42:58 +000025 if verbose:
26 print 'succeeded...',
27 l.call(func)
28 l.close()
29 if verbose:
30 print 'worked!'
31 break
Roger E. Masse2362b581996-12-16 20:25:44 +000032else:
Thomas Woutersb9fa0a82000-08-04 13:34:43 +000033 raise TestSkipped, 'Could not open any shared libraries'