home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 June / maximum-cd-2011-06.iso / DiscContents / LibO_3.3.1_Win_x86_install_multi.exe / libreoffice1.cab / test_dl.py < prev    next >
Encoding:
Python Source  |  2011-02-15  |  968 b   |  39 lines

  1. #! /usr/bin/env python
  2. """Test dlmodule.c
  3.    Roger E. Masse  revised strategy by Barry Warsaw
  4. """
  5. from test.test_support import verbose,TestSkipped, import_module
  6. dl = import_module('dl', deprecated=True)
  7.  
  8. sharedlibs = [
  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.  
  15. def 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 TestSkipped, 'Could not open any shared libraries'
  35.  
  36.  
  37. if __name__ == '__main__':
  38.     test_main()
  39.