~malept/ubuntu/lucid/python2.6/dev-dependency-fix

« back to all changes in this revision

Viewing changes to Lib/test/test_dl.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-02-13 12:51:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090213125100-uufgcb9yeqzujpqw
Tags: upstream-2.6.1
ImportĀ upstreamĀ versionĀ 2.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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()