Home | History | Annotate | Download | only in test
      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)
      8 
      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'),
     14     ]
     15 
     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'
     36 
     37 
     38 if __name__ == '__main__':
     39     test_main()
     40