summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger E. Masse <rmasse@newcnri.cnri.reston.va.us>1996-12-16 20:25:44 (GMT)
committerRoger E. Masse <rmasse@newcnri.cnri.reston.va.us>1996-12-16 20:25:44 (GMT)
commit2362b58952040ca44b082b3cd4470ecde8d518ff (patch)
tree9db9e2c503ec84849dea81e506201edc34e05757
parent14ed5fb1ec62bd69b6eb8994ab17645bbd4adba7 (diff)
downloadcpython-2362b58952040ca44b082b3cd4470ecde8d518ff.zip
cpython-2362b58952040ca44b082b3cd4470ecde8d518ff.tar.gz
cpython-2362b58952040ca44b082b3cd4470ecde8d518ff.tar.bz2
Revised strategy for testing recomended by bwarsaw
-rwxr-xr-xLib/test/test_dl.py54
1 files changed, 28 insertions, 26 deletions
diff --git a/Lib/test/test_dl.py b/Lib/test/test_dl.py
index b8cb0c04..dcc3ec2 100755
--- a/Lib/test/test_dl.py
+++ b/Lib/test/test_dl.py
@@ -1,32 +1,34 @@
#! /usr/bin/env python
"""Test dlmodule.c
- Roger E. Masse
+ Roger E. Masse revised strategy by Barry Warsaw
"""
-filename = '/usr/lib/libresolv.so'
-try:
- import dl
-except ImportError:
- # No test if no library
- raise SystemExit
+verbose = 0
+if __name__ == '__main__':
+ verbose = 1
-try:
- import os
- n = os.popen('/bin/uname','r')
- if n.readlines()[0][:-1] != 'SunOS':
- raise SystemExit
- l = dl.open('/usr/lib/libresolv.so')
-except:
- # No test if not SunOS (or Solaris)
- raise SystemExit
+import dl
-# Try to open a shared library that should be available
-# on SunOS and Solaris in a default place
-try:
- open(filename,'r')
-except IOError:
- # No test if I can't even open the test file with builtin open
- raise SystemExit
+sharedlibs = [
+ # SunOS/Solaris
+ ('/usr/lib/libresolv.so', 'gethostent'),
+ ]
-l = dl.open(filename)
-a = l.call('gethostent')
-l.close()
+for s, func in sharedlibs:
+ try:
+ if verbose:
+ print 'trying to open:', s,
+ l = dl.open(s)
+ except dl.error:
+ if verbose:
+ print 'failed'
+ pass
+ else:
+ if verbose:
+ print 'succeeded...',
+ l.call(func)
+ l.close()
+ if verbose:
+ print 'worked!'
+ break
+else:
+ print 'Could not open any shared libraries'