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