mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Test for the dl module. This only works for SunOS and Solaris.
I've attempted to make a test that silently exits if either module dl is not present, we're not on a Sun OS, or a standard shared library ('/usr/lib/libresolv.so') is not found... Otherwise, It does a simple test of dlmodule on that library. I *think* this would be ok to add to testall.py but I'll wait till I hear some feedback on the liberalness of this approach.
This commit is contained in:
parent
2cc8163e30
commit
7eee08d04f
1 changed files with 32 additions and 0 deletions
32
Lib/test/test_dl.py
Executable file
32
Lib/test/test_dl.py
Executable file
|
@ -0,0 +1,32 @@
|
|||
#! /usr/bin/env python
|
||||
"""Test dlmodule.c
|
||||
Roger E. Masse
|
||||
"""
|
||||
filename = '/usr/lib/libresolv.so'
|
||||
try:
|
||||
import dl
|
||||
except ImportError:
|
||||
# No test if no library
|
||||
raise SystemExit
|
||||
|
||||
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
|
||||
|
||||
# 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
|
||||
|
||||
l = dl.open(filename)
|
||||
a = l.call('gethostent')
|
||||
l.close()
|
Loading…
Add table
Add a link
Reference in a new issue